background image

 

                                                                                                                                                                       

 

 

 

 

Contents 

*About keyestudio ........................................................................................................... 2 

*References and After-sales Service .......................................................................... 3 

*Warning ............................................................................................................................. 3 

*Copyright .......................................................................................................................... 4 

1.Description

 ................................................................................................................. 5 

2.Features

 ....................................................................................................................... 6 

3.Parameters

 .................................................................................................................. 7 

4.Kit List

 ........................................................................................................................... 7 

5.Get Started with Arduino ........................................................................................ 13 

(1) Install Arduino IDE ......................................................................................... 13 

(2)Keyestudio UNO Development Board ...................................................... 16 

(2) Install Driver ..................................................................................................... 22 

(4)Arduino IDE Setting ........................................................................................ 28 

(5)Start the First Program .................................................................................. 33 

6.Installation of the Solar Tracking Device ........................................................... 37 

7.Projects ......................................................................................................................... 84 

Project 1: LED Blinks ............................................................................................ 84 

Project 2: Adjust LED Brightness ..................................................................... 90 

Project 3

Push Button Module ...................................................................... 98 

Project 4: Passive Buzzer .................................................................................. 104 

Содержание KS0530

Страница 1: ...5 Get Started with Arduino 13 1 Install Arduino IDE 13 2 Keyestudio UNO Development Board 16 2 Install Driver 22 4 Arduino IDE Setting 28 5 Start the First Program 33 6 Installation of the Solar Tracking Device 37 7 Projects 84 Project 1 LED Blinks 84 Project 2 Adjust LED Brightness 90 Project 3 Push Button Module 98 Project 4 Passive Buzzer 104 ...

Страница 2: ... Project 10 Lithium Power Module Powering by Solar Energy or Via USB Cable Smart phone charging Module 139 Project 11 Solar Panel Device with Multiply Functions 145 8 Trouble Shooting 159 1 Solar tracking device doesn t respond 159 2 USB port can t recognized by computer 159 3 The servo doesn t rotate 160 9 Resources 160 About keyestudio Keyestudio is a best selling brand owned by KEYES Corporatio...

Страница 3: ...eyestudio com References and After sales Service 1 Download Profile https fs keyestudio com KS0530 2 If you find any parts missing or encounter any troubles please feel free to contact us service keyestudio com We will update projects and products continuously according to your sincere advice Warning 1 This product contains tiny parts screws copper pillars Therefore keep it out of reach of childre...

Страница 4: ... KEYES DIY ROBOT co LTD All products under keyestudio brand can t be copied sold and resold by anyone or any companies without authorization If you re interested in our products please contact with our sales representatives fennie keyestudio com DIY Solar Tracking Kit ...

Страница 5: ...he solar tracking kit launched by KEYES is based on Arduino It consists of 4 ambient light sensors 2 DOF servos a solar panel and so on aiming at converting light energy into electronic energy and charging power devices ...

Страница 6: ...ource programming device it is easy to build The 11 projects from simple to complex guide you step by step You can either start from those basic ones like learning how to control a signal module or sensor or aim at a more sophisticated one the one integrating most of these components What s more you can also alter the code or connect it with other sensors or modules through the Lego parts reserved...

Страница 7: ... Lego jacks LCD 1602 modules and solar panels add technologies to it High extension preserve IIC UART SPI ports and Lego jacks and extend other sensors and modules Basic programming program in C language with Arduino IDE 3 Parameters Working voltage 5v Input voltage 3 7V Maximum output current 1 5A Maximum power dissipation 7 5W 4 Kit List When you receive this delicate kit please confirm whether ...

Страница 8: ...8 Picture Component Qua ntity 1 Acrylic Board 5 1 2 Wooden Board 3mm 4 1 3 Keyestudio UNO Development Board 1 4 Mounting Bracket Kit 1 ...

Страница 9: ...ucture 4 6 1860 Lithium Battery Holder 1 7 keyestudio Temperature and Humidity Sensor in Building Block Structure 1 8 keyestudio Passive Buzzer Module in Building Block Structure 1 9 keyestudio Lithium Power Module Powered by Solar Energy and Via USB Cable 1 ...

Страница 10: ...udio Yellow LED Module 1 11 keyestudio Single channel Push Button Module 1 12 Keyestudio I2C1602 Module 1 13 keyestudio BH1750FVI Digital Light Intensity Module IIC Interface 1 14 Solar Panel with Tape And Wires 1 ...

Страница 11: ... 2 0 40MM Screwdriver 1 16 3 0 40MM Screwdriver 1 17 USB Cable 1 18 Smart Phone Charging Module 1 19 M3 8MM Flat Head Screw 29 20 M3 14MM Flat Head Screw 4 21 M3 Nickle plated Nut 6 22 M4 Nickle plated Nut 2 ...

Страница 12: ...12 23 M4 8MM Round Head Screw 2 24 M3 45MM Double Pass Copper Pillar 8 25 M3 10MM Double Pass Copper Pillar 7 26 Lego Part 4265c 18 27 Lego Part 43093 18 28 M3 6 6MM Single Pass Copper Pillar 4 ...

Страница 13: ... 3P 26AWG 200mm F F DuPont Wire 7 31 4P F F 26AWG 350mm DuPont Wire 1 32 4P 26AWG 200mm DuPont Wire 1 33 20cm M to F DuPont Wire 1 34 Plastic String 4 35 Plastic Pipe 1 5 Get Started with Arduino 1 Install Arduino IDE ...

Страница 14: ...low There are various versions of IDE for Arduino Just download a version compatible with your system Here we will show you how to download and install the windows version of Arduino IDE There are two versions of IDE for WINDOWS system You can choose between the installer exe and the Zip file For installer it can be directly downloaded without the need of installing it manually However for Zip pac...

Страница 15: ...15 Click JUST DOWNLOAD ...

Страница 16: ... to connect it to a computer via a USB cable and power it by an external power supply of DC 7 12 The core processor of this board is ATMEGA328P AU with chip ATMEGA16U2 which can be UART to USB conversion plug It has 14 digital input output pins of which 6 can be used as PWM outputs 6 analog inputs a 16 MHz crystal oscillator a USB connection a power jack 1 ICSP headers and a reset button It contro...

Страница 17: ...ended DC7 12V Digital I O Pins 14 个 D0 D13 PWM Digital I O Pins 6 个 D3 D5 D6 D9 D10 D11 Analog Input Pins 6 个 A0 A5 Flash Memory 32 KB ATMEGA328P PU of which 0 5 KB used by bootloader SRAM 2 KB ATMEGA328P PU EEPROM 1 KB ATMEGA328P PU Clock Speed 16 MHz Element and Interfaces ...

Страница 18: ... often called the SPI serial peripheral interface and can be considered an extension of the output In fact slave the output devices under the SPI bus host When connecting to PC program the firmware to ATMEGA328P AU Serial Communication Pin Connect to serial communication 4Pins GND VCC 3 3V or 5V controlled by slide switch RX TX GND Ground pins ...

Страница 19: ...c The pin D3 D5 D6 D9 D10 and D11 can be used to generate PWM For digital port you can connect through female headers or through pin headers labeled S of 2 54mm pitch AREF For Analog reference Sometimes used to set an external reference voltage 0 5V as the upper limit of analog input pins SDA IIC communication pin SCL IIC communication pin ICSP In Circuit Serial Programming Header ICSP is an AVR a...

Страница 20: ...tal pin 13 When the pin is HIGH value the LED is on when the pin is LOW it s off TX LED Onboard you can find the label TX transmit When the board communicates via serial port send the message TX led flashes RX LED Onboard you can find the label RX receive When the board communicates via serial port receive the message RX led flashes Power LED LED on means that your circuit board is correctly power...

Страница 21: ...components Convert an external input DC7 12V voltage into DC 5V then switch DC 5V to the processor and other components output DC 5V drive current is 2A DC Power Jack The board can be supplied with an external power DC7 12V from the DC power jack IOREF Used to configure the operating voltage of microcontrollers Use it less RESET Header Connect an external button to reset the board The function is ...

Страница 22: ...ort you can connect through female headers or through pin headers labeled S of 2 54mm pitch IIC Communication Pin Connect to the IIC communication 4Pins GND VCC 3 3V or 5V controlled by slide switch SDA SCL RESET Button You can reset your board to start the program from the initial status 2 Install Driver Windows 10 The driver will be automatically installed if you plug control board to your compu...

Страница 23: ...23 You need to install it manually if your computer is other Windows system We will take win7 system as example Right click and click Open file location to find out the drivers folder ...

Страница 24: ...24 Copy driver folder to D drive Right click Computer Properties Device Manager You will view Unknown Device ...

Страница 25: ...25 Click Unknown devices to select Update Device Management Click Browse manually ...

Страница 26: ...26 Find the drivers file and tap Next ...

Страница 27: ...27 Click install this driver software anyway Then click Close and check the serial port ...

Страница 28: ...28 Return to Device Manager page if the driver is installed Then check correct port 4 Arduino IDE Setting Click icon and open Arduino IDE ...

Страница 29: ...hen downloading the sketch to the board you must select the correct name of Arduino board that matches the board connected to your computer Click Tools Board to choose the corresponding board as shown below ...

Страница 30: ...30 Then select the correct COM port you can see the corresponding COM port after the driver is successfully installed ...

Страница 31: ...31 The functions of all symbols are demonstrated below ...

Страница 32: ...r Arduino board C Used to create shortcut window of a new sketch D Used to directly open an example sketch E Used to save the sketch F Used to send the serial data received from board to the serial monitor Please note that the setting of Windows system and Mac system differs in COM only as shown below ...

Страница 33: ...nload and install the driver of development board next we will burn a code to show Hello World in the monitor void setup initialize serial communication at 9600 bits per second Serial begin 9600 void loop print out Hello world Serial println Hello world ...

Страница 34: ...34 delay 1000 delay 1 second Then let s make monitor show Hello World Open Arduino IDE and select Arduino UNO ...

Страница 35: ...35 Set COM port as shown below Click to start compiling the program and check errors Click to upload the program upload successfully ...

Страница 36: ...36 Upload the program successfully open serial monitor and set baud rate to 9600 Monitor will print Hello World each 1s ...

Страница 37: ...37 Congratulations You have finished the first program 6 Installation of the Solar Tracking Device Peel the sticker off the Acrylic boards first Part 1 Components Needed ...

Страница 38: ...38 Installation Diagram Prototype Part 2 ...

Страница 39: ...39 Components Needed Installation Diagram ...

Страница 40: ...40 Prototype Part 3 ...

Страница 41: ...41 Components Needed Installation Diagram ...

Страница 42: ...42 Prototype Part 4 Components Needed ...

Страница 43: ...43 Installation Diagram Prototype ...

Страница 44: ...44 Part 5 Components Needed Installation Diagram mind the installation direction ...

Страница 45: ...45 Prototype Part 6 Components Needed ...

Страница 46: ...46 Installation Diagram Prototype Part 7 ...

Страница 47: ...47 Components Needed ...

Страница 48: ...48 Installation Diagram mind the installation direction Prototype Part 8 ...

Страница 49: ...49 Components Needed Installation Diagram ...

Страница 50: ...50 Prototype Part 9 Components Needed ...

Страница 51: ...51 Installation Diagram mind the installation direction of the servo Prototype Part 10 ...

Страница 52: ...52 Components Needed Installation Diagram ...

Страница 53: ...53 Prototype Part 11 adjust the angle of the servo before starting this step Components Needed adjust the angle of the servo marked in red circle ...

Страница 54: ...e 10 set the initial angle to 10 degree keep the solar panels upright to detect the strongest light const byte ud_servopin 10 define the servo rotating upwards and downwards and its control pin void setup ud_servo attach ud_servopin set the control pin of the servo ud_servo write ud_angle delay 1000 void loop ...

Страница 55: ...55 Installation Diagram pay attention to the angle of the servo as shown in the picture Prototype Part 12 ...

Страница 56: ...56 Components Needed Installation Diagram ...

Страница 57: ...57 Prototype Part 13 Components Needed ...

Страница 58: ...58 Installation Diagram Prototype Part 14 adjust the angle of the servo before starting this step ...

Страница 59: ...rotating right and left int lr_angle 90 set the initial angle to 90 degreeset the initial angle to 90 degree const byte lr_servopin 9 define the name of the servo rotating upwards and downwards and its control pin void setup lr_servo attach lr_servopin set the control pin of the servo lr_servo write lr_angle return to initial angle delay 1000 ...

Страница 60: ...60 void loop Installation Diagram ...

Страница 61: ...61 Prototype Part 15 Components Needed ...

Страница 62: ...62 Installation Diagram Prototype Part 16 ...

Страница 63: ...63 Components Needed Installation Diagram ...

Страница 64: ...64 Prototype Part 17 Components Needed ...

Страница 65: ...65 Installation Diagram Prototype Part 18 ...

Страница 66: ...66 Components Needed Installation Diagram ...

Страница 67: ...67 Prototype Part 19 Components Needed ...

Страница 68: ...68 Installation Diagram ...

Страница 69: ...69 Prototype Start Wiring ...

Страница 70: ...70 The battery holder aims to power the smart phone charging module Plug the jack of the battery holder to the BAT end of the power module ...

Страница 71: ...71 Connect the servo downward to D9 on the main board ...

Страница 72: ...72 Connect the servo upward to D10 on the main board ...

Страница 73: ...73 Connect the solar panel to the SOLAR end ...

Страница 74: ...74 Connect the LCD module to A4 and A5 blue line to A4 and green line to A5 ...

Страница 75: ...75 Connect the push button module to D2 ...

Страница 76: ...76 Connect the passive buzzer to D6 ...

Страница 77: ...77 Connect the temperature and humidity sensor to D7 ...

Страница 78: ...78 Connect the digital light intensity module to the main board blue line to SDA and green line to SCL ...

Страница 79: ...79 Keep the LED display in front of you as reference the photoresistor on the left is connected to A0 ...

Страница 80: ...80 Keep the LED display in front of you as reference the photoresistor on the right is connected to A1 ...

Страница 81: ...81 Keep the LED display in front of you as reference the photoresistor on the back is connected to A2 ...

Страница 82: ...82 Keep the LED display in front of you as reference the photoresistor ahead is connected to A3 ...

Страница 83: ...83 Wire up the power module to power the main board G to GND and V to VIN ...

Страница 84: ...r module and then move to a more intricate one solar tracking combining these components together Note G marked on each sensor and module is the negative pole and connected to G or GND on the sensor shield or control board V is the positive pole and interfaced with V VCC or 5V on the sensor shield or control board Project 1 LED Blinks 1 Description ...

Страница 85: ...n indicator in the circuit The LED can flash diverse color by altering the delay time in the test code When in control power on GND and VCC the LED will be on if S end is high level nevertheless it will go off 2 Parameters Control interface digital port Working voltage DC 3 3 5V Pin spacing 2 54mm LED display color yellow 3 Component Needed Keyestudio UNO 1 keyestudio Yellow LED Module 1 20cm 3pin...

Страница 86: ...86 USB Cable 1 4 Connection Diagram The pin and S of LED module are connected to the pin G 5V and D3 port of expansion board ...

Страница 87: ...D3 void setup pinMode LED OUTPUT initialize digital pin LED as an output void loop the loop function runs over and over again forever digitalWrite LED HIGH turn the LED on HIGH is the voltage level delay 1000 wait for a second digitalWrite LED LOW turn the LED off by making the voltage LOW delay 1000 wait for a second ...

Страница 88: ...ode LED OUTPUT This function can denote that the pin is INPUT or OUTPUT digitalWrite LED HIGH When pin is OUTPUT we can set it to HIGH output 5V or LOW output 0V 8 Extension Practice The LED flashes for 1s through the test result Therefore delay time can change flash frequency Test Code keyestudio sun_follower ...

Страница 89: ...lize digital pin LED as an output void loop the loop function runs over and over again forever digitalWrite LED HIGH turn the LED on HIGH is the voltage level delay 100 wait for a second digitalWrite LED LOW turn the LED off by making the voltage LOW delay 100 wait for a second Upload code and observe the state of the LED ...

Страница 90: ...g the analog output via digital means Digital control is used to generate square waves with different duty cycles a signal that constantly switches between high and low levels to control the analog output In general the input voltage of port are 0V and 5V What if the 3V is required Or what if switch among 1V 3V and 3 5V We can t change resistor constantly For this situation we need to control by P...

Страница 91: ...5V which is like showing movie The movie we watch are not completely continuous It actually outputs 25 pictures per second In this case the human can t tell it neither does PWM If want different voltage need to control the ratio of 0 and 1 The more 0 1 signals output per unit time the more accurately control 2 Components Needed Keyestudio UNO 1 keyestudio Yellow LED Module 1 20cm 3pin F F 26AWG Du...

Страница 92: ...92 3 Connection Diagram 4 Test Code keyestudio sun_follower lesson 2 1 PWM http www keyestudio com ...

Страница 93: ...ut void loop for value 0 value 255 value value 1 analogWrite LED value LED lights gradually light up delay 5 delay 5MS for value 255 value 0 value value 1 analogWrite LED value LED gradually goes out delay 5 delay 5MS 5 Test Results Upload test code successfully LED gradually becomes brighter then darker like human breath ...

Страница 94: ...4 Round 2 2 3 4 Until number 2 is not established for loop is over After knowing this order go back to code for int value 0 value 255 value value 1 for int value 255 value 0 value value 1 The two for statements make value increase from 0 to 255 then reduce from 255 to 0 then increase to 255 infinitely loop There is a new function in the following analogWrite ...

Страница 95: ...y write the digital pins with PWM function such as pin 2 3 4 5 6 7 8 9 10 11 12 13 44 45 46 PWM is a technology to obtain analog quantity through digital method Digital control forms a square wave and the square wave signal only has two states of turning on and off that is high or low levels By controlling the ratio of the duration of turning on and off a voltage varying from 0 to 5V can be simula...

Страница 96: ...tom the duty cycle of first square wave is 0 and its corresponding value is 0 The LED brightness is lowest that is turn off The more time high level lasts the brighter the LED Therefore the last duty cycle is 100 which correspond to 255 LED is brightest 25 means darker PWM mostly is used for adjusting the LED brightness or rotation speed of motor It plays vital role in controlling smart robot car ...

Страница 97: ...io sun_follower lesson 2 2 PWM http www keyestudio com define LED 3 define the pin of LED as D10 int value void setup pinMode LED OUTPUT initialize digital pin LED as an output void loop for value 0 value 255 value value 1 analogWrite LED value LED lights gradually light up delay 20 delay 20MS ...

Страница 98: ...y 20MS Upload code to development board the LED s blink frequency is slower isn t it Project 3 Push Button Module 1 Description In this project we intend to use the push button module to control the LED 2 Parameters Working voltage DC 3 3 5V Control signal digital signal Size 34 22 15mm Weight 3 8g ...

Страница 99: ...pin F F 26AWG DuPont Line 2 USB Cable 1 4 Connection Diagram Please note that the pins G V and S on the push button module should be connected with G V and D2 on the development board respectively while the pins G V and S on the LED module should be linked with G V and D3 on the development board respectively ...

Страница 100: ... push button module keyestudio sun_follower lesson 3 1 button http www keyestudio com define button 2 define the pin of the push button module as D2 volatile int buttonState the state of the level output by the push button module void setup ...

Страница 101: ...nState Automatically wrap and output the digital signal read from digital port 2 delay 100 delay in 100ms 6 Test Results After uploading test code powering the module up and open the serial monitor to set the baud rate to 9600 the value 1 high level output by the push button module is shown on the serial monitor and when the button is pushed it changes to 0 low level ...

Страница 102: ... the baud rate to 9600 pinMode pin INPUT use the function pinMode to tell Arduino whether it is an output pin or an input pin digitalRead pin read the digital level of pins be HIGHT OT LOW 8 Extension Project control the LED by the push button module keyestudio sun_follower lesson 3 2 ...

Страница 103: ...of the level output by the push void setup Serial begin 9600 set baud rate to 9600 pinMode button INPUT initialize digital pin button as an input pinMode LED OUTPUT initialize digital pin LED as an output void loop buttonState digitalRead button read the state of the push button module if buttonState 0 if the button is pressed digitalWrite LED HIGH the LED lights up ...

Страница 104: ...o make experiments For this lesson we design circuit to emit sound The universal sound components are buzzer and horns Buzzer is easier to use And buzzer includes about active buzzer and passive buzzer In this experiment we adopt passive buzzer While using passive buzzer we can control different sound by inputting square waves with distinct frequency During the experiment we control code to make b...

Страница 105: ...e digital port Working voltage DC 3 3 5V 3 Components Needed Keyestudio UNO 1 Keyestudio Passive Buzzer 1 200mm 26AWG 3P F F DuPont Line USB Cable 1 4 Connection Diagram The G V and S pins of passive buzzer are connected to G V and D6 ...

Страница 106: ...106 5 Test Code keyestudio sun_follower lesson 4 1 buzzer http www keyestudio com define buzzer 6 buzzer pin to D6 void setup pinMode buzzer OUTPUT set the digital pin 6 as output ...

Страница 107: ...in 250ms tone buzzer 294 output the sound with frequency of 294Hz delay 250 delay in 250ms tone buzzer 330 delay 250 tone buzzer 349 delay 250 tone buzzer 392 delay 250 tone buzzer 440 delay 250 tone buzzer 494 delay 250 tone buzzer 532 delay 250 noTone buzzer stop sound output delay 1000 ...

Страница 108: ...ent board power amplifier module will emit do re mi fa so la si do 7 Extension Practice play music keyestudio sun_follower lesson 4 2 buzzer http www keyestudio com define buzzer 6 buzzer pin to D6 void setup pinMode buzzer OUTPUT set digital 6 to OUTPUT ...

Страница 109: ...thday to You void birthday tone buzzer 294 buzzer outputs a sound with 294Hz delay 250 delay in 250ms tone buzzer 440 delay 250 tone buzzer 392 delay 250 tone buzzer 532 delay 250 tone buzzer 494 delay 500 tone buzzer 392 delay 250 tone buzzer 440 ...

Страница 110: ... buzzer 587 delay 250 tone buzzer 532 delay 500 tone buzzer 392 delay 250 tone buzzer 784 delay 250 tone buzzer 659 delay 250 tone buzzer 532 delay 250 tone buzzer 494 delay 250 tone buzzer 440 delay 250 tone buzzer 698 delay 375 tone buzzer 659 ...

Страница 111: ...lay Module 1 Description With I2C communication module this is a display module that can show 2 lines with 16 characters per line It shows blue background and white word and connects to I2C interface of MCU which highly save the MCU resources On the back of LCD display there is a blue potentiometer for adjusting the ...

Страница 112: ...nient for you to fix on other devices 2 Parameters I2C address 0x27 Backlight blue white Power supply voltage 5V Adjustable contrast GND A pin that connects to ground VCC A pin that connects to a 5V power supply SDA A pin that connects to analog port 20 for IIC communication SCL A pin that connects to analog port 21 for IIC communication 3 Components Needed Keyestudio UNO 1 Keyestudio I2C1602 I2C1...

Страница 113: ...113 USB Cable 1 4 Connection Diagram Note the pin GND VCC SDA and SCL of 1602LCD module are connected to GND 5V SDA and SCL of IIC communication ...

Страница 114: ...C h includes the LiquidCrystal_I2C Library LiquidCrystal_I2C lcd 0x27 16 2 set the LCD address to 0x27 for a 16 chars and 2 line display void setup lcd init Print a message to the LCD lcd backlight set backlight lcd setCursor 0 0 set Cursor at 0 0 lcd print Hello World display Hello World lcd setCursor 0 1 set Cursor at 0 1 ...

Страница 115: ...ording to connection diagram and power on 1602 LCD will display Hello World at the first row and show Hello Keyes at the second row Note wire up connection diagram upload code and power on You can adjust the potentiometer on the back of 1602LCD display module to display the character strings ...

Страница 116: ...ce to changes in voltage What s more the sensor comes with an anti reverse insertion terminal with a pitch of 2 54mm to facilitate the wiring It is also compatible with many kinds of microcontrollers such the Arduino microcontroller series Here we apply this sensor with the Arduino microcontroller The S signal end of the sensor should be input to the analog pin of Arduino to detect the variation i...

Страница 117: ...ule 1 keyestudio Yellow LED Module 1 15cm 3pin F F 26AWG DuPont Line 2 USB Cable 1 4 Connection Diagram Please note that the pins G V and S on the push button module should be connected with G V and A0 on the expansion board respectively while the pins G V and S on the LED module should be linked with G V and 3 respectively ...

Страница 118: ...118 5 Test Code keyestudio sun_follower lesson 6 1 photovaristor http www keyestudio com define photos A0 photoresistance pin to A0 ...

Страница 119: ...e digital pin LED as an output void loop value analogRead photos read the value detected by the sensor Serial println value if value 300 when the analog value is less than 300 digitalWrite LED HIGH the LED lights up else when the analog value is bigger than 300 digitalWrite LED LOW the LED is off delay 100 delay in 100ms ...

Страница 120: ...etting the baud rate to 9600 the serial monitor prints the value detected by the ambient light sensor And when we block the sensor from light the valued printed gets smaller When the value sensed is less than 300 the LED lights up otherwise it remains off Project 7 DHT11 Temperature and Humidity Sensor 1 Description ...

Страница 121: ...ital module and temperature and humidity sensing technology ensuring high reliability and excellent long term stability It includes a resistive element and a NTC temperature measuring device 2 Parameters Working voltage 5 V Working temperature 0 50 error of 2 Humidity 20 90 RH 5 RH error Interface digital port 3 Components needed Keyestudio UNO 1 keyestudio DHT11Humidity and Temperature Sensor 1 2...

Страница 122: ...122 USB Cable 1 4 Connection Diagram Please note that when we conduct this experiment we need to import the library file of DHT11 first 5 Test Code keyestudio sun_follower ...

Страница 123: ...HT define DHT11_PIN 7 define the DHT11 as the digital port 7 void setup Serial begin 9600 void loop int chk chk DHT read DHT11_PIN read data switch chk case DHTLIB_OK break case DHTLIB_ERROR_CHECKSUM check and return errors break case DHTLIB_ERROR_TIMEOUT timeout and return errors break default ...

Страница 124: ... print temperature Serial println DHT temperature delay 200 6 Test Results After uploading test code powering it up via USB cable and open the serial monitor to set the baud rate to 9600 the serial monitor displays the value of the current humidity and temperature as shown below ...

Страница 125: ...tal light intensity As shown in the picture below BH1750 is composed of a photodiode an operational amplifier an ADC acquisition a crystal oscillator etc The photodiode converts the input optical signal into an electrical signal through the photovoltaic effect After being amplified by the operational amplifier circuit the voltage is collected by the ADC ...

Страница 126: ...d why the integrated IC is used directly instead of photodiodes BH1750 leads out the clock line and data line The single chip microcomputer can communicate with the BH1750 module through the I2C protocol You can choose the working mode of the BH1750 or you can extract the illuminance data of the BH1750 register 2 Parameters I2C digital interface supporting a maximum rate of 400Kbps The output is I...

Страница 127: ...error 20 GND power ground SDA I2C bus data pin SCL I2C bus clock pin VCC power supply voltage 3 5V 3 Components Needed Keyestudio UNO 1 Keyestudio BH1750FVI IIC Interface Digital Light Intensity Module 1 350mm 4pin F F 26AWG DuPont Line 1 USB Cable 1 ...

Страница 128: ...128 4 Connection Diagram 5 Test Code keyestudio sun_follower lesson 8 BH1750 http www keyestudio com include Wire h include BH1750 h BH1750 lightMeter void setup ...

Страница 129: ... esp8266 you can select SCL and SDA pins using Wire begin D4 D3 For Wemos Lolin D1 Mini Pro and the Ambient Light shield use Wire begin D2 D1 lightMeter begin Serial println F BH1750 Test begin void loop float lux lightMeter readLightLevel Serial print Light Serial print lux Serial println lx delay 1000 ...

Страница 130: ...monitor prints the value of the ambient light intensity unit lux And when light source gets closer the value becomes bigger as shown below Note since the I2C bus can have multiple devices with different addresses when the digital light intensity module is used together with the I2C LCD1602 module there is no conflict because they have different addresses ...

Страница 131: ...C bias voltage to the voltage of the potentiometer and obtains the voltage difference output For the servo used in this project the brown wire is the ground the red one is the positive wire and the orange one is the signal wire The rotation angle of servo motor is controlled by regulating the duty cycle of PWM Pulse Width Modulation signal The standard cycle of PWM signal is 20ms 50Hz Theoreticall...

Страница 132: ...different brand motor the same signal may have different rotation angle More details 2 Parameters Working voltage DC 4 8V 6V Operating angle range about 180 at 500 2500 μsec Pulse width range 500 2500 μsec ...

Страница 133: ... 4 8V 1 5 0 1kg cm DC 6V Stop current 850mA DC 4 8V 1000mA DC 6V Standby current 3 1mA DC 4 8V 4 1mA DC 6V Lead length 250 5 mm Appearance size 22 9 12 2 30mm Weight 9 1 g without servo horn 3 Components Needed Keyestudio UNO 1 Sunfounder Servo 1 USB Cable 1 4 Connection Diagram Note The servo is connected to G GND V VCC 9 The brown wire of the ...

Страница 134: ...n external power supply must be used Because the current requirement for driving the steering gear is relatively large and the current of the development board is far from enough If the external power supply is not connected the development board is likely to be burned out 5 Test Code1 keyestudio sun_follower lesson 9 1 servo http www keyestudio com ...

Страница 135: ...e to 90 degrees delay 1000 servopulse servoPin 180 rotate to 180 degrees delay 1000 void servopulse int pin int myangle the function of plus int pulsewidth map myangle 0 180 500 2500 Map angle to pulse width for int i 0 i 10 i output pulse digitalWrite pin HIGH set the servo interface level to high delayMicroseconds pulsewidth the delay time of pulse width digitalWrite pin LOW turn the servo inter...

Страница 136: ...rol the servo that is use the servo library file of Arduino The following link is for your reference https www arduino cc en Reference Servo 6 Test Code2 Library file is used but the connection diagram remains the same keyestudio sun_follower lesson 9 2 servo http www keyestudio com include Servo h include the library code Servo myservo ...

Страница 137: ... servo to digital port 9 void loop rotate from 0 degree to 180 degrees for int i 0 i 180 i myservo write i delay 20 delay 1000 wait for 1s rotate from 180 degree to 0 degree for int i 180 i 0 i myservo write i delay 20 delay 1000 wait for 1s ...

Страница 138: ...es of the servo function 1 Attach pin set the pin of the servo 2 write angle it is used to set the rotation angle of the steering gear The range of angle is 0 to 180 3 read it is used to read the angle of the steering gear and can be understood as reading the value in the last write command 4 attached Determine whether the servo parameters have been sent to the interface where the servo is connect...

Страница 139: ... a charging port for solar panels which can supply power for an external lithium battery In addition this module has a boost module which can increase the voltage of batteries to 6 6V The DIP switch on the module is the OUTPUT switch of 6 6V The pin G and V can output 6 6V and the pin S can read the battery voltage after the resistance 1 2 voltage The mobile phone charging module is a lithium batt...

Страница 140: ...Cable Charging Port Micro USB HP2 0MM port for solar panels Input Voltage of ports of the solar panel 4 4 6V constant voltage charging 4 15 4 24V Max Charging Current 800mA Output Port 3 P 2 54mm Pins Input Voltage 6 6V Max Output Current 1A Batteries Single cell Lithium Battery Environmental Attribute ROHS ...

Страница 141: ...5V Output voltage 5 士 0 1V Output current Rated 1 1 5A single cell lithium battery input maximum 1 5A single cell lithium battery input Conversion efficiency Up to 96 Switching frequency 500KHz Working temperature industrial grade 40 C to 85 C Full load heating 30 C Quiescent current 130uA ...

Страница 142: ...142 3 Schematic Diagram of Lithium Power Module Powering by Solar Energy or Via USB Cable 4 Features Lithium Power Module Powering by Solar Energy or Via USB Cable ...

Страница 143: ...the output port of power is interfaced with the lithium battery holder rechargeable batteries and saves the electric energy into batteries This is the switch Slide to ON end then the external lithium battery will be connected supplying to the expansion board on the contrary slide to OFF then the current of lithium battery will be disconnected ...

Страница 144: ...144 You can charge the lithium battery via USB cable Smart phone charging Module Place a lithium cell in the PH2 0 terminal Connect the USB port and the smart phone via a USB cable to charge ...

Страница 145: ... sensor or module Can we combine them together and make a device which is able to display various functions The answer is positive And in this lesson we will write a set of test code to make the solar tracking device perform all functions illustrated before The wiring is almost the same but no need to attach the LED module to it 2 Flow Chart ...

Страница 146: ...ty value Read T H value LCD shows light intensity value and T H value No Yes Adjust the angle of the servo 3 Connection In this experiment the connection is almost the same But we will connect two servos to D9 and D10 4 photoresistor modules to A0 A1 A3 and A3 and others remain unchanged 4 Test Code keyestudio sun_follower lesson 11 sun_follower ...

Страница 147: ...he library code dht11 DHT define DHT11_PIN 7 define the DHT11 as the digital pin 7 include Servo h Servo lr_servo define the name of the servo rotating right and left Servo ud_servo define the name of the servo rotating upwards and downwards const byte interruptPin 2 the pin of button the corruption is disrupted int lr_angle 90 set the initial angle to 90 degree ...

Страница 148: ...al pin of the servo rotating right and left const byte ud_servopin 10 define the control signal pin of the servo rotating clockwise and anticlockwise unsigned int light save the variable of light intensity byte error 15 Define the error range to prevent vibration byte m_speed 10 set delay time to adjust the speed of servo the longer the time the smaller the speed byte resolution 1 set the rotation...

Страница 149: ... the control pin of servo pinMode l_state INPUT set the mode of pin pinMode r_state INPUT pinMode u_state INPUT pinMode d_state INPUT pinMode interruptPin INPUT_PULLUP the button pin is set to input pull up mode attachInterrupt digitalPinToInterrupt interruptPin adjust_resolution FALLING External interrupt touch type is falling edge adjust_resolution is interrupt service function ISR lcd init init...

Страница 150: ...ead_light read the light intensity of bh1750 read_dht11 read the value of temperature and humidity LcdShowValue Lcd shows the values of light intensity temperature and humidity serial monitor displays the resistance of the photoresistor and the angle of servo Serial print L Serial print L Serial print R Serial print R Serial print U Serial print U ...

Страница 151: ...g delay time the function of the servo void ServoAction int L analogRead l_state read the analog voltage value of the sensor 0 1023 int R analogRead r_state int U analogRead u_state int D analogRead d_state system adjusting left and right abs is the absolute value function if abs L R error L R Determine whether the error is within the acceptable range otherwise adjust the steering gear lr_angle re...

Страница 152: ...r L R Determine whether the error is within the acceptable range otherwise adjust the steering gear lr_angle resolution increase the angle lr_servo attach lr_servopin connect servo if lr_angle 180 limit the rotation angle of servo lr_angle 180 lr_servo write lr_angle output the angle of servo delay m_speed else if abs L R error Determine whether the error is within the acceptable range otherwise a...

Страница 153: ...olution reduce the angle ud_servo attach ud_servopin connect servo if ud_angle 10 limit the rotation angle of servo ud_angle 10 ud_servo write ud_angle output the angle of servo delay m_speed else if abs U D error U D Determine whether the error is within the acceptable range otherwise adjust the steering gear ud_angle resolution increase the angle ud_servo attach ud_servopin connect servo if ud_a...

Страница 154: ...stable and make no change in angle ud_servo detach release the pin of servo ud_servo write ud_angle output the angle of servo void LcdShowValue char str1 5 char str2 2 char str3 2 dtostrf light 5 0 str1 Format the light value data as a string left aligned dtostrf temperature 2 0 str2 dtostrf humidity 2 0 str3 LCD1602 display display the value of the light intensity ...

Страница 155: ...print lux display the value of temperature and humidity lcd setCursor 0 1 lcd print temperature lcd setCursor 2 1 lcd print C lcd setCursor 5 1 lcd print humidity lcd setCursor 7 1 lcd print display the accuracy of rotation lcd setCursor 11 1 lcd print res lcd setCursor 15 1 lcd print resolution ...

Страница 156: ...lse if light 100 lcd setCursor 8 0 lcd print lcd setCursor 6 0 lcd print light else if light 1000 lcd setCursor 9 0 lcd print lcd setCursor 6 0 lcd print light else if light 10000 lcd setCursor 9 0 lcd print lcd setCursor 6 0 lcd print light else if light 100000 lcd setCursor 10 0 ...

Страница 157: ...tMeter readLightLevel read the light intensity detected by BH1750 void read_dht11 int chk chk DHT read DHT11_PIN read data switch chk case DHTLIB_OK break case DHTLIB_ERROR_CHECKSUM check and return error break case DHTLIB_ERROR_TIMEOUT Timeout and return error break default ...

Страница 158: ...ction disrupts service void adjust_resolution tone buzzer 800 100 delay 10 delay to eliminate vibration if digitalRead interruptPin if resolution 5 resolution else resolution 1 5 Test Results After uploading the test code and powering it up the servos rotate to the ...

Страница 159: ...d push the button on the servo to adjust the accuracy of the angle to make it rotate faster And 1 means 1 degree per push and 5 represents 5 degrees per push And it can also be altered by changing the variable m_speed in the code 8 Trouble Shooting 1 Solar tracking device doesn t respond A 1 Ensure the battery capacity fully charged 2 Check if the wiring up is correct 2 USB port can t recognized b...

Страница 160: ... the battery capacity fully charged or confirm whether the power button has been pressed 2 Check the setting of the angle If it is struck please cut off the power immediately in case to damage it 9 Resources https fs keyestudio com KS0530 V1 0 ...

Отзывы: