Keyestudio KS0436 Скачать руководство пользователя страница 180

180

Содержание KS0436

Страница 1: ...will need to build the circuit and robot projects for the keyestudio REV4 Board When you re done with this guide you will have built five great projects and acquired the know how to create countless...

Страница 2: ...cuit 3 Potentiometer 43 Circuit 4 Photo Resistor 55 Circuit 5 Buzzer 63 Circuit 6 Button 73 Circuit 7 74HC595 And Segment Display 86 Circuit 8 4 Digit Segment Display 99 Circuit 9 LED Matrix Display 1...

Страница 3: ...otor 198 Circuit 19 Relay 208 Circuit 20 PIR Motion Sensor 216 GET STARTED WITH ROBOT PROJECTS 226 ROBOT BASEPALTE ASSEMBLY 227 Circuit 21 Motor Basics 233 Circuit 22 Light Following Robot 248 Circuit...

Страница 4: ...ke blinking an LED light or spinning an electric motor This board is capable of taking the world of electronics and relating it to the physical world in a real and tangible way The keyestudio REV4 Boa...

Страница 5: ...5 connect it to a computer with a USB cable or power it via an external DC power jack DC 7 12V or via female headers Vin GND DC 7 12V to get started Hardware Overview...

Страница 6: ...a half size transparent breadboard good for small projects It has 2 power rails on both sides a standard double strip in the middle with 30 columns and 10 rows a total of 400 tie in points This tiny b...

Страница 7: ...7...

Страница 8: ...tudio baseplate makes circuit building easier by keeping the REV4 Board microcontroller and the breadboard connected without the worry of disconnecting or damaging your circuit 1 To begin with collect...

Страница 9: ...e Using four screws affix the REV4 Board to the four stand off holes found on the baseplate 3 Peel the adhesive backing off the breadboard 4 Carefully align the breadboard over its spot on the basepla...

Страница 10: ...10 Your baseplate is now assembled...

Страница 11: ...Environment will allow you to program the REV4 Board to do exactly what you want It s like a word processor for coding With an internet capable computer open up your favorite browser and type the fol...

Страница 12: ...12 click the Arduino icon to open...

Страница 13: ...ted below Verify Compile Check the code for errors Upload Upload the current Sketch to the Arduino New Create a new blank Sketch Open Show a list of Sketches Save Save the current Sketch Serial Monito...

Страница 14: ...14 Select Your Board And Serial Port NOTE select the Arduino REV4 but if you are not sure which ports should choose Go to your computer panel and check the Port out in the Device Manger...

Страница 15: ...15...

Страница 16: ...16 The Kit contains extensive electronic components Below shows you a part of kit components...

Страница 17: ...e described in more detail as you progress through the circuits As you work your way through each circuit you will learn to use new and more complicated parts to accomplish increasingly complex tasks...

Страница 18: ...program embedded electronic components In this circuit you ll write code that makes an LED blink on and off What You Need REV4 Baseplate Red LED x 1 220 Resistor x 1 Jumper wires x 2 USB cable x 1 Co...

Страница 19: ...y let electricity flow through them in one direction LEDs can also burn out if too much electricity flows through them so you should always use a resistor to limit the current when you wire an LED int...

Страница 20: ...protect sensitive components like LEDs The strength of a resistor measured in ohms is marked on the body of the resistor using small colored bands Each color stands for a number which you can look up...

Страница 21: ...21 Wiring Diagram Check out the schematics and wiring diagram below to see how everything is connected Schematics...

Страница 22: ...22...

Страница 23: ...the positive side of the LED and the other side of the LED going to GND Upload Code 1 Connect the REV4 Board to a USB port on your computer 2 Open the program in the code folder Circuit 1 LED or dire...

Страница 24: ...hy you wrote it the way you did The first line of code is int ledPin 10 define digital pin 10 As the comment above it explains this is giving a name to the pin that the LED is connected to You can cha...

Страница 25: ...ediately start again Input Or Output pinMode ledPin OUTPUT Before you can use one of the digital pins you need to tell the UNO Board whether it is an INPUT or OUTPUT We use a built in function called...

Страница 26: ...period is in milliseconds so if you want the LED to blink twice as fast change the value try 500 or 2000 Upload the sketch again and you should see the LED start to blink more quickly or slowly What...

Страница 27: ...27 After downloading this program in the experiment you will see the LED flashing on for one second then off for one second The blinking LED experiment is now completed Thank you...

Страница 28: ...28 Troubleshooting Upload failed Make sure you have assembled the circuit correctly and verified and uploaded the code to your board Check out the Board and Serial Port...

Страница 29: ...he principle is almost the same In this circuit you ll write code that makes six LEDs blink on and off one by one Furthermore you can also use three LEDs to simulate the traffic light Now let s start...

Страница 30: ...30 Check out the wiring below to see how everything is connected Schematics...

Страница 31: ...31...

Страница 32: ...y and paste the code below on the Ardunio IDE 3 Select UPLOAD to program the sketch on the UNO Board int BASE 2 the I O pin for the first LED int NUM 6 the number of LEDs void setup for int i BASE i B...

Страница 33: ...e by one delay 200 delay Code Explanation Single line comments start with and everything up until the end of that line is considered a comment Comments are a great way to leave notes in your code expl...

Страница 34: ...34 What You Will See...

Страница 35: ...ke sure you have assembled the circuit correctly and verified and uploaded the code to your board Check out the Board and Serial Port Troubleshooting Upload failed Make sure you have assembled the cir...

Страница 36: ...36 LED Not Lighting Up Make sure you connect the LED correctly or try other LEDs...

Страница 37: ...ffic light What You Need REV4 Baseplate Red LED x 1 Yellow LED x 1 Green LED x 1 220 Resistor x 3 Jumper wires x 4 USB cable x 1 Hookup Guide Check out the hookup table below to see how everything is...

Страница 38: ...38...

Страница 39: ...39...

Страница 40: ...ith red LED as output pinMode yellowled OUTPUT set the pin with yellow LED as output pinMode greenled OUTPUT set the pin with green LED as output void loop digitalWrite greenled HIGH turn on green LED...

Страница 41: ...elay 500 wait 0 5 second digitalWrite yellowled LOW turn off yellow LED delay 500 wait 0 5 second digitalWrite redled HIGH turn on red LED delay 5000 wait 5 second digitalWrite redled LOW turn off red...

Страница 42: ...traffic light This circuit design is very similar with the one in LED chase effect The green light will turn on for 5 seconds and then off followed by the yellow light blinking for 3 times and then re...

Страница 43: ...D In this circuit you ll use a potentiometer as an input device to control the speed at which your LED blinks Here may involves a new concept PWM to control the brightness of an LED Check more details...

Страница 44: ...potentiometer is a 3 pin variable resistor When powered with 5V the middle pin outputs a voltage between 0V and 5V depending on the position of the knob on the potentiometer By tracking the position o...

Страница 45: ...switched between on and off This on off pattern can simulate voltages in between full on 5 Volts and off 0 Volts by changing the portion of the time the signal spends on versus the time that the signa...

Страница 46: ...tates LOW and HIGH corresponding to the voltage output of 0V and 5V If merely make use of LOW and HIGH state it cannot control the brightness of an LED light However if convert the voltage output of 0...

Страница 47: ...47 Analog output it needs to call the analogWrite function of ARDUINO and this analogWrite function can be controlled in the range of 0 255...

Страница 48: ...48 Hookup Guide The input of potentiometer is analog so we connect it to analog port and LED to PWM pin Different PWM signals can regulate the LED brightness...

Страница 49: ...49...

Страница 50: ...pin 11 initialize digital pin 11 PWM output int val 0 Temporarily store variables value from the sensor void setup pinMode ledpin OUTPUT define digital pin 11 as output Serial begin 9600 set baud rate...

Страница 51: ...ze analog pin 0 A variable is a placeholder for values that may change in your code You must introduce or declare variables before you use them Here we re declaring a variable called potPosition of ty...

Страница 52: ...nction to read the value on an analog pin Serial println val This is the line that actually prints the trimpot value to the monitor What You Will See You should see the LED brighter or dim in accordan...

Страница 53: ...53 You should see numeric values print out in the monitor Turning the potentiometer changes the value...

Страница 54: ...ure you have assembled the circuit correctly and verified and uploaded the code to your board Ensure that you are on the correct Board and Serial Port No values in Serial Monitor Make sure that you ha...

Страница 55: ...In this circuit you ll be using a photoresistor which changes resistance based on how much light the sensor receives Using this sensor you can make a simple night light that turns on when the room ge...

Страница 56: ...if the incident light is weak the resistance increases Photo resistor is widely applied to various light control circuit such as light control and adjustment optical switches etc Photovaristor is an...

Страница 57: ...57 Hookup Guide The photoresistors like regular resistors are not polarized and can be installed in either direction...

Страница 58: ...58...

Страница 59: ...d After the connection let s begin the program compiling The program is similar to the one of PWM For change details please refer to the Sample Code below int potpin 0 initialize analog pin 0 connecte...

Страница 60: ...60 val map analogRead potpin 0 1023 0 255 Serial println val display the value of val analogWrite ledpin val turn on the LED and set up brightness maximum output value 255 delay 10 wait for 0 01...

Страница 61: ...61 What You Will See You can change the light intensity around the photovaristor and see corresponding brightness change of the LED See the light intensity on the serial monitor...

Страница 62: ...62...

Страница 63: ...Buzzer x 1 Jumper wires x2 USB cable x 1 Component Introduction Passive Buzzer Buzzers can be categorized as active and passive ones The difference between the two is that an active buzzer has a built...

Страница 64: ...ep Different frequencies produce different sounds By the buzzer you can even play a song Hookup Guide Wiring the buzzer connected to the REV4 board the red positive to the pin8 black wire negative to...

Страница 65: ...65...

Страница 66: ...66...

Страница 67: ...AD to program the sketch on the UNO Board After the connection let s begin the program compiling int buzzer 8 select digital IO pin for the buzzer void setup pinMode buzzer OUTPUT set digital IO pin p...

Страница 68: ...delay for i 0 i 100 i output a frequency sound digitalWrite buzzer HIGH sound digitalWrite buzzer LOW not sound delay 2 2ms delay Test Reult Done uploading the code to the board the passive buzzer wil...

Страница 69: ...69 Troubleshooting No sound is playing Check your wiring of the buzzer It s easy to misalign a pin with a jumper wire or reverse the buzzer...

Страница 70: ...audible beep from active buzzer Test code is showed below int buzzer 2 initialize digital IO pin that controls the buzzer void setup pinMode buzzer OUTPUT set pin mode as output void loop digitalWrit...

Страница 71: ...71 is connected to Digital pin 2 of REV4 The short lead is connected to ground Troubleshooting No sound playing Check your wiring of the buzzer It s easy to misalign a pin with a...

Страница 72: ...72 jumper wire or reverse the buzzer...

Страница 73: ...ys on your keyboard to the buttons on your remote control In this circuit you ll learn how to use the button to control the LED on and off using digital input What You Need REV4 Baseplate Button x 1 R...

Страница 74: ...n momentary switches are best used for intermittent user input cases reset button and keypad buttons These switches have a nice tactile clicky feedback when you press them Note that the different colo...

Страница 75: ...75...

Страница 76: ...76...

Страница 77: ...ould be easy for you In this program we add a statement of judgment Here we use an if statement Arduino IDE is based on C language so statements of C language such as while switch can certainly be use...

Страница 78: ...Write ledpin LOW else digitalWrite ledpin HIGH Code Explanation Single line comments start with and everything up until the end of that line is considered a comment Comments are a great way to leave n...

Страница 79: ...D remains off After the above process the button controlled LED experiment is completed The simple principle of this experiment is widely used in a variety of circuit and electric appliances Troublesh...

Страница 80: ...ou have declared your buttons as inputs Think about How to make responder effect Create your own exciting game You can try to use three buttons to control three LEDs one button used as reset button to...

Страница 81: ...81...

Страница 82: ...tton int yellowpin 4 initialize pin for yellow button int greenpin 3 initialize pin for green button int restpin 2 initialize pin for reset button int red int yellow int green void setup pinMode redle...

Страница 83: ...if green LOW GREEN_YES void RED_YES execute the code until red light is on end cycle when reset button is pressed while digitalRead restpin 1 digitalWrite redled HIGH digitalWrite greenled LOW digital...

Страница 84: ...ite yellowled HIGH clear_led void GREEN_YES execute the code until green light is on end cycle when reset button is pressed while digitalRead restpin 1 digitalWrite redled LOW digitalWrite greenled HI...

Страница 85: ...85 digitalWrite greenled LOW digitalWrite yellowled LOW Press the button to turn corresponding LED on and off...

Страница 86: ...cuit In this circuit we will use the 74HC595 shift register to control the segment display The segment display will show number from 0 9 What You Need REV4 Baseplate 1 digit 7 seg Display x 1 74HC595...

Страница 87: ...s off For the common cathode display connect the common cathode COM to GND When the anode level of a certain segment is high the segment is on when the anode level of a certain segment is low the segm...

Страница 88: ...88 In this experiment we use a common cathode display Below is the seven segment pin diagram...

Страница 89: ...ut to a different one of the eight registers We are essentially controlling the output of each of the eight pins one at a time and as we move one clock signal forward we switch to the next output pin...

Страница 90: ...90 Hookup Guide Check out the circuit diagram and hookup table below to see how everything is connected...

Страница 91: ...91 The following table shows the seven segment display 74HC595 pin correspondence table 74HC595 pin Seven shows remarkable...

Страница 92: ...to 5V GND pin 8 and OE pin 13 to ground Connection DS ST_CP and SH_CP pin DS pin 14 connected to REV4 board Digital pin 2 ST_CP pin 12 latch pin connected to REV4 Digital pin 4 SH_CP pin 11 clock pin...

Страница 93: ...93 seven segment display corresponding pin A G and DP and then each foot in a 220 ohm resistor in series...

Страница 94: ...94...

Страница 95: ...below on the Ardunio IDE 3 Select UPLOAD to program the sketch on the UNO Board int latchPin 4 int clockPin 5 int dataPin 2 define three pins void setup pinMode latchPin OUTPUT pinMode clockPin OUTPUT...

Страница 96: ...verything up until the end of that line is considered a comment Comments are a great way to leave notes in your code explaining why you wrote it the way you did The first thing we do is define the thr...

Страница 97: ...are using to be digital outputs void setup pinMode latchPin OUTPUT pinMode clockPin OUTPUT pinMode dataPin OUTPUT three pins as output What You Will See Hookup well and upload the code to board you ca...

Страница 98: ...have assembled the circuit correctly and verified and uploaded the code to your board Ensure that you are on the correct Board and Serial Port No number showing on 1 digit Segment Check out the wiring...

Страница 99: ...this circuit In this lesson you will learn how to use a 4 digit 7 segment display We make the display show changing numbers among 0000 9999 What You Need REV4 Baseplate 4 digit 7 seg Display x 1 220 R...

Страница 100: ...is a semiconductor light emitting device Its basic unit is a light emitting diode LED The display features one decimal point per digit The hardware interface is twelve two rows of six through hole pi...

Страница 101: ...101...

Страница 102: ...102 Hookup Guide Check out the circuit diagram and hookup table below to see how everything is connected...

Страница 103: ...103...

Страница 104: ...en the program in the code folder Circuit 8 or directly copy and paste the code below on the Ardunio IDE 3 Select UPLOAD to program the sketch on the UNO Board int a 1 int b 2 int c 3 int d 4 int e 5...

Страница 105: ...stment for clock void setup pinMode d1 OUTPUT pinMode d2 OUTPUT pinMode d3 OUTPUT pinMode d4 OUTPUT pinMode a OUTPUT pinMode b OUTPUT pinMode c OUTPUT pinMode d OUTPUT pinMode e OUTPUT pinMode f OUTPU...

Страница 106: ...106 int a 0 int b 0 int c 0 int d 0 unsigned long currentMillis millis while d 0 while millis currentMillis 10 Display 1 a Display 2 b Display 3 c Display 4 d currentMillis millis d if d 9 c d 0...

Страница 107: ...107 if c 9 b c 0 if b 9 a b 0 if a 9 a 0 b 0 c 0 d 0 void WeiXuan unsigned char n...

Страница 108: ...2 HIGH digitalWrite d3 HIGH digitalWrite d4 HIGH break case 2 digitalWrite d1 HIGH digitalWrite d2 LOW digitalWrite d3 HIGH digitalWrite d4 HIGH break case 3 digitalWrite d1 HIGH digitalWrite d2 HIGH...

Страница 109: ...italWrite d4 LOW break default digitalWrite d1 HIGH digitalWrite d2 HIGH digitalWrite d3 HIGH digitalWrite d4 HIGH break void Num_0 digitalWrite a HIGH digitalWrite b HIGH digitalWrite c HIGH digitalW...

Страница 110: ...HIGH digitalWrite c HIGH digitalWrite d LOW digitalWrite e LOW digitalWrite f LOW digitalWrite g LOW digitalWrite dp LOW void Num_2 digitalWrite a HIGH digitalWrite b HIGH digitalWrite c LOW digitalWr...

Страница 111: ...HIGH digitalWrite c HIGH digitalWrite d HIGH digitalWrite e LOW digitalWrite f LOW digitalWrite g HIGH digitalWrite dp LOW void Num_4 digitalWrite a LOW digitalWrite b HIGH digitalWrite c HIGH digital...

Страница 112: ...OW digitalWrite c HIGH digitalWrite d HIGH digitalWrite e LOW digitalWrite f HIGH digitalWrite g HIGH digitalWrite dp LOW void Num_6 digitalWrite a HIGH digitalWrite b LOW digitalWrite c HIGH digitalW...

Страница 113: ...IGH digitalWrite c HIGH digitalWrite d LOW digitalWrite e LOW digitalWrite f LOW digitalWrite g LOW digitalWrite dp LOW void Num_8 digitalWrite a HIGH digitalWrite b HIGH digitalWrite c HIGH digitalWr...

Страница 114: ...gitalWrite c HIGH digitalWrite d HIGH digitalWrite e LOW digitalWrite f HIGH digitalWrite g HIGH digitalWrite dp LOW void Clear clear the screen digitalWrite a LOW digitalWrite b LOW digitalWrite c LO...

Страница 115: ...rite dp LOW void pickNumber unsigned char n select number switch n case 0 Num_0 break case 1 Num_1 break case 2 Num_2 break case 3 Num_3 break case 4 Num_4 break case 5 Num_5 break case 6 Num_6 break...

Страница 116: ...Display unsigned char x unsigned char Number take x as coordinate and display number WeiXuan x pickNumber Number delay 1 Clear clear the screen What You Will See Hookup well and upload the code to bo...

Страница 117: ...117 Troubleshooting No number jumping on 4 digit Segment Check out the wiring between the 1 digit LED display and REV4...

Страница 118: ...D Matrix Display About this circuit In this circuit you will learn how to control the LED matrix showing the number What You Need REV4 Baseplate LED matrix display x 1 220 Resistor x 8 Jumper wires x...

Страница 119: ...column at level 0 simultaneously LED lights up that is between high and low level For instance if you want to light up the first LED connect pin 7 to high level and pin A to low level if you want to...

Страница 120: ...120 Hookup Guide Check out the circuit diagram and hookup table below to see how everything is connected...

Страница 121: ...121...

Страница 122: ...3 Select UPLOAD to program the sketch on the UNO Board define an array to store 0 unsigned char Text 0x00 0x1c 0x22 0x22 0x22 0x22 0x22 0x1c void Draw_point unsigned char x unsigned char y draw point...

Страница 123: ...123 for j 0 j 8 j if data 0x01 Draw_point j i data 1 void setup int i 0 for i 2 i 18 i pinMode i OUTPUT clear_ void loop show_num void clear_ void clear screen for int i 2 i 10 i...

Страница 124: ...124 digitalWrite i LOW for int i 0 i 8 i digitalWrite i 10 HIGH What You Will See Hookup well and upload the code to board the LED matrix is displaying the 0...

Страница 125: ...125 Troubleshooting No number displaying on 8 8 LED matrix Check out the wiring between the 8 8 LED matrix display and REV4...

Страница 126: ...g Hello world is usually the first thing that programming tutorials will have you do in a new language Now we re going to print out real text using a Liquid Crystal Display LCD What You Need REV4 Base...

Страница 127: ...oject will make it super portable and allow you to integrate up to 32 characters 16x2 of information On the back of LCD display there is a blue potentiometer You can turn the potentiometer to adjust t...

Страница 128: ...er supply SDA A pin that connects to analog port A4 for IIC communication SCL A pin that connects to analog port A5 for IIC communication Hookup Guide Check out the circuit diagram and hookup table be...

Страница 129: ...129...

Страница 130: ...ode 1 Note Before you can run this make sure that you have installed the LiquidCrystal library or re install it if necessary Otherwise your code won t work 2 Connect the REV4 Board to a USB port on yo...

Страница 131: ...he sketch on the UNO Board include Wire h include LiquidCrystal_I2C h LiquidCrystal_I2C lcd 0x27 16 2 set the LCD address to 0x27 for a 16 chars and 2 line display void setup lcd init initialize the l...

Страница 132: ...t we wish to use the Liquid Crystal library After uploading this code make sure the backlight is lit up and adjust the potentiometer all the way around until you see the text message In the setup func...

Страница 133: ...ing the potentiometer if you can t make out the words clearly If you have any issues make sure your code is correct and double check your connections Troubleshooting LCD Display Not Clear Remember you...

Страница 134: ...134...

Страница 135: ...s circuit you can use a small low cost sensor like the LM35 to make devices that track and respond to temperature What You Need REV4 Baseplate LM35 temperature sensor x 1 Red LED x 1 Green LED x 1 Yel...

Страница 136: ...ure sensor This temperature sensor has three legs One connects to 5V one to ground and the voltage output from the second leg varies proportionally to changes in temperature Hookup Guide See how every...

Страница 137: ...137...

Страница 138: ...138...

Страница 139: ...the code below on the Ardunio IDE 3 Select UPLOAD to program the sketch on the UNO Board void setup Serial begin 9600 pinMode 13 OUTPUT pinMode 12 OUTPUT pinMode 11 OUTPUT void loop int vol analogRea...

Страница 140: ...talWrite 12 LOW digitalWrite 11 LOW else if vol 28 vol 30 digitalWrite 13 LOW digitalWrite 12 HIGH digitalWrite 11 LOW else if vol 30 low temperature area and LED setup digitalWrite 13 LOW digitalWrit...

Страница 141: ...the temperature value Corresponding LED will be turned on in accordance with corresponding temperature range Put a bag filled with hot water close to the sensor When the temperature is lower than 28 g...

Страница 142: ...142 turns on if greater than 30 red LED turns on...

Страница 143: ...circuit you will learn how to use a DHT11 Temperature and Humidity Sensor It s accurate enough for most projects that need to keep track of humidity and temperature reading What You Need REV4 Baseplat...

Страница 144: ...cted This sensor includes a resistive element and a sense of wet NTC temperature measuring devices It has excellent quality fast response anti interference ability and high cost performance advantages...

Страница 145: ...plied application and even the most demanding one Convenient connection special packages can be provided according to users need Hookup Guide Check out the circuit diagram and hookup table below to se...

Страница 146: ...146...

Страница 147: ...omputer 3 Open the program in the code folder Circuit 12 or directly copy and paste the code below on the Ardunio IDE 4 Select UPLOAD to program the sketch on the UNO Board include dht11 h dht11 DHT d...

Страница 148: ...switch chk case DHTLIB_OK Serial print OK t break case DHTLIB_ERROR_CHECKSUM Serial print Checksum error t break case DHTLIB_ERROR_TIMEOUT Serial print Time out error t break default Serial print Unk...

Страница 149: ...149 Serial println DHT temperature 1 delay 1000 What You Will See...

Страница 150: ...150 After uploading the code open the serial monitor it will show the temperature and humidity value of current environment...

Страница 151: ...151 Troubleshooting No Data Display Double check that you have plugged the DTH11 sensor in correctly Make sure the wiring is no wrong Note that here use a 10K Resistor...

Страница 152: ...circuit In this circuit you will learn how to use a flame sensor to trigger a buzzer making an alarm when detecting the fire What You Need REV4 Baseplate Flame sensor x 1 Active buzzer x 1 10K Resist...

Страница 153: ...n infrared receiving tube specially designed to detect fire and then convert the flame brightness to fluctuating level signal The signals are then input into the central processor and be dealt with ac...

Страница 154: ...154 analog pin As shown below...

Страница 155: ...155 Hookup Guide Check out the circuit diagram and hookup table below to see how everything is connected...

Страница 156: ...156...

Страница 157: ...fire approaching the voltage it reads is around 0 3V when there is fire approaching the voltage it reads is around 1 0V The nearer the fire the higher the voltage So in the beginning of the program yo...

Страница 158: ...ut Serial begin 9600 set baud rate at 9600 void loop val analogRead flame read the analog value of the sensor Serial println val output and display the analog value if val 600 when the analog value is...

Страница 159: ...159 What You Will See After uploading the code once the sensor detects the flame the buzzer will immediately make a sound If no fire everything is normal...

Страница 160: ...160 Troubleshooting Buzzer Not Sound Double check that you have plugged them in correctly The longer lead of the buzzer is positive end So does the flame sensor...

Страница 161: ...161 Note that here use a 10K Resistor...

Страница 162: ...is circuit In this circuit you will learn how to use two tilt ball switches to control two LED lights on and off What You Need REV4 Baseplate Tilt ball switch x 2 Red LED x 2 220 Resistor x 2 10K Resi...

Страница 163: ...twig is the equivalent of a button and is used as a digital input Inside the tilt switch is a ball that make contact with the pins when the case is upright Tilt the case over and the balls don t touc...

Страница 164: ...164 Hookup Guide Check out the circuit diagram and hookup table below to see how everything is connected...

Страница 165: ...165...

Страница 166: ...e code below on the Ardunio IDE 3 Select UPLOAD to program the sketch on the UNO Board int LedPinA 5 int LedPinB 6 int ButtonPinA 7 int ButtonPinB 4 int buttonStateA 0 int buttonStateB 0 int brightnes...

Страница 167: ...IGH brightnessA 255 brightnessA if buttonStateA LOW brightnessA 0 brightnessA analogWrite LedPinB brightnessA Serial print brightnessA Serial print buttonStateB digitalRead ButtonPinB if buttonStateB...

Страница 168: ...168 brightnessB analogWrite LedPinA brightnessB Serial println brightnessB delay 5 What You Will See Tilt the circuit to one side one LED gradually turns on and another LED turns off...

Страница 169: ...169 Troubleshooting LED Not Lighting Double check that you have plugged them in correctly Make sure the connection no wrong...

Страница 170: ...rcuit 15 Vibration Switch About this circuit In this circuit you will learn how to test the vibration switch What You Need REV4 Baseplate Vibration switch x 1 10K Resistor x 1 Jumper wires x 3 USB cab...

Страница 171: ...a electronic switch that can sense the intensity of vibration and transfer the result to the circuit device and activate the circuit to start working Hookup Guide Check out the circuit diagram and hoo...

Страница 172: ...172...

Страница 173: ...173...

Страница 174: ...he code below on the Ardunio IDE 3 Select UPLOAD to program the sketch on the UNO Board define SensorLED 13 define SensorINPUT 2 unsigned char state 0 void setup pinMode SensorLED OUTPUT pinMode Senso...

Страница 175: ...orLED LOW void blink digital input of the sensor falling triggering interruption function state What You Will See Done uploading the code vibrate the desk where the sensor placed once the sensor detec...

Страница 176: ...t this circuit In this circuit you will learn how to use a microphone sound sensor to turn an LED on and off What You Need REV4 Baseplate Sound sensor x 1 Red LED x 1 Potentiometer 1 220 Resistor x 2...

Страница 177: ...cal signals It works opposite to a speaker These microphones are widely used in electronic circuits to detect minor sounds or air vibrations which in turn are converted to electrical signals for furth...

Страница 178: ...es The sound signals air vibrations passes through the porous material and falls on the diaphragm through the hole shown in the image above Hookup Guide Check out the circuit diagram and hookup table...

Страница 179: ...179...

Страница 180: ...180...

Страница 181: ...3 Select UPLOAD to program the sketch on the UNO Board int LEDpin 7 set pin for LED void setup Serial begin 9600 pinMode LEDpin OUTPUT void loop int Soundvalue analogRead A0 read the input analog val...

Страница 182: ...tentiometer the analog value of A0 changes After adjusting the potentiometer blow air into the MIC and observe the data in the serial monitor For example the displayed data is less than 300 before blo...

Страница 183: ...entiometer to adjust the sensitivity of led light Do uploading the code open the serial monitor and set the baud rate to 9600 Clapping your hands you should see the LED turn on for 5 seconds then off...

Страница 184: ...184...

Страница 185: ...185 Troubleshooting LED Not Lighting Double check that you have plugged them in correctly The longer lead is the positive end Make sure the sound sensor and potentiometer are assembled correctly...

Страница 186: ...hey can be used in experiments to calculate speed and acceleration and they can be used in robotics to avoid obstacles This circuit will walk you through the basics of using an ultrasonic distance sen...

Страница 187: ...ent function the ranging accuracy can reach to 3mm The modules includes ultrasonic transmitters receiver and control circuit Distance sensors work by sending pulses of light or sound out from a transm...

Страница 188: ...188 TECH SPECS Operating Voltage 5V DC Operating Current 15mA Operating Frequency 40khz Maximum Detection Distance 3 5m Minimum Detection Distance 3 4cm Sensing Angle less than 15 degrees PINS...

Страница 189: ...189 Hookup Guide Check out the circuit diagram and hookup table below to see how everything is connected...

Страница 190: ...this make sure that you have installed the LCD library or re install it if necessary Otherwise your code won t work 2 Connect the REV4 Board to a USB port on your computer 3 Open the program in the co...

Страница 191: ...efine echoPin 7 Echo Pin define trigPin 8 Trigger Pin define LEDPin 13 Onboard LED int maximumRange 200 Maximum range needed int minimumRange 0 Minimum range needed long duration distance Duration use...

Страница 192: ...y bouncing soundwaves off of it digitalWrite trigPin LOW delayMicroseconds 2 digitalWrite trigPin HIGH delayMicroseconds 10 digitalWrite trigPin LOW duration pulseIn echoPin HIGH Calculate the distanc...

Страница 193: ...EDPin HIGH else turn LED OFF to indicate successful reading lcd setCursor 3 1 lcd print distance digitalWrite LEDPin LOW if distance 10 lcd setCursor 4 1 lcd print if distance 100 lcd setCursor 5 1 lc...

Страница 194: ...194 What You Will See...

Страница 195: ...195 Move your hand or a large flat object closer and farther away from the distance sensor As the object approaches the LCD display screen will show the distance being read from the sensor...

Страница 196: ...196 Troubleshooting LCD Display Not Clear Remember you can adjust the contrast using the potentiometer if you can t make out the words clearly...

Страница 197: ...197...

Страница 198: ...how to wire a servo and control it with code Servo motors can be told to move to a specific position and stay there Here we will turn a potentiometer to make the servo rotate in a certain angle What Y...

Страница 199: ...signal terminal PWM signal Included with your servo motor you will find a variety of white motor mounts that connect to the shaft of your servo You may choose to attach any mount you wish for the cir...

Страница 200: ...20ms 50 Hz and the pulse width is distributed between 1ms 2ms The pulse width corresponds to the rotation angle 0 90 of servo Hookup Guide Check out the circuit diagram and hookup table below to see h...

Страница 201: ...201...

Страница 202: ...202...

Страница 203: ...in the code folder Circuit 18 or directly copy and paste the code below on the Ardunio IDE 4 Select UPLOAD to program the sketch on the UNO Board include Servo h Servo myservo define steering engine v...

Страница 204: ...r code explaining why you wrote it the way you did The first line of source code is include Servo h The include command adds a library to your Arduino program After you include a library you can use t...

Страница 205: ...urn The servo will mimic the movement of the potentiometer twisting in the same clockwise or counter clockwise direction If you ve attached a white mount to the servo this movement will be easier to s...

Страница 206: ...206...

Страница 207: ...207...

Страница 208: ...t 19 Relay About this circuit In this circuit you will learn how to use a relay and other tiny sensors to turn on an LED What You Need REV4 Baseplate Relay x 1 4N35 1 4007 Diode 1 8050 Transistor 1 Re...

Страница 209: ...by a low power signal with complete electrical isolation between control and controlled circuits or where several circuits must be controlled by one signal It s widely used in remote control remote se...

Страница 210: ...o drive silicon phototransistors 4007 Diode Used to protect the circuit NPN 8050 Transistor Used as a switch Hookup Guide Check out the circuit diagram and hookup table below to see how everything is...

Страница 211: ...211...

Страница 212: ...212 pay attention to using the NPN 8050 transistor the plug direction of 4N35 relay and diode Upload Code...

Страница 213: ...d paste the code below on the Ardunio IDE 3 Select UPLOAD to program the sketch on the UNO Board int relay 3 relay turn on trigger signal active high void setup pinMode relay OUTPUT define port attrib...

Страница 214: ...ll See Here when S is in high level relay switches to the ON end LED will be turned on In the test result you should be able to hear the relay contacts click and see the LED turning on and off at 1 se...

Страница 215: ...ubleshooting LED Not Lighting Double check that you have plugged them in correctly The longer lead is the positive end No Clicking Sound Check the transistor you use is NPN8050 whether plug in the rig...

Страница 216: ...lesson we will create an alarm system to detect motion combining usage of PIR sensor 1602 LCD and LED What You Need REV4 Baseplate PIR motion sensor x 1 1602 LCD display x 1 Red LED x 1 220 Resistor...

Страница 217: ...ls It can be applied to a variety of occasions to detect the movement of human body Parameters Input Voltage DC 3 3V 18V Working Current 15uA Working Temperature 20 85 Output Voltage High 3V Low 0V Ou...

Страница 218: ...218 Hookup Guide Check out the circuit diagram and hookup table below to see how everything is connected...

Страница 219: ...219...

Страница 220: ...this make sure that you have installed the LCD library or re install it if necessary Otherwise your code won t work 2 Connect the REV4 Board to a USB port on your computer 3 Open the program in the co...

Страница 221: ...de Wire h include LiquidCrystal_I2C h LiquidCrystal_I2C lcd 0x27 16 2 byte sensorPin 6 byte indicator 10 void setup lcd init initialize the lcd lcd init Print a message to the LCD lcd backlight pinMod...

Страница 222: ...lWrite indicator state if state 1 lcd setCursor 2 0 lcd print Somebody is lcd setCursor 2 1 lcd print in this area else if state 0 lcd setCursor 2 0 lcd print No one lcd setCursor 2 1 lcd print No one...

Страница 223: ...223 What You Will See Move your hand or a large flat object closer and farther away from the...

Страница 224: ...rea and LED lights up it is reminding of you that somebody is here Otherwise it will tell you by displaying No one on LCD and LED off Troubleshooting LED Not Lighting Double check that you have plugge...

Страница 225: ...225 LCD Display Not Clear Remember you can adjust the contrast using the potentiometer if you can t make out the words clearly...

Страница 226: ...earn all about DC motors and motor drivers by building your own robot You ll first learn motor control basics By adding an IR receiver remote control the robot to move freely By adding an IR receiver...

Страница 227: ...more strips and weld the strips to the two motors Cut and attach two short pieces of dual lock adhesive tape to your motors Be sure that your motors are mirror images of each other when you attach the...

Страница 228: ...wheel is firmly mounted on the Clear Acrylic plate with the two screws and nuts Then cut and attach a short piece of dual lock adhesive tape to Acrylic plate Stick the two motors and Omni directional...

Страница 229: ...Remember that the two motors should be mirror images of each other 4 Attach the wheels by sliding them onto the plastic shafts on the gear motor The shaft is flat on one side as is the wheel coupler...

Страница 230: ...230...

Страница 231: ...attach one piece to the back of the battery holder Adhere the second piece to the bottom of the baseplate directly in the middle Press the battery holder to the baseplate so that the two pieces of Dua...

Страница 232: ...232 Once you re finished it s time to build the circuit...

Страница 233: ...you will learn the basic concepts behind motor control You ll use what is known as a motor controller or motor driver board to power and spin the motor accordingly What You Need Gear Motor x 2 TB6612F...

Страница 234: ...r Driver may look complicated but it s easy to use The TB6612FNG motor driver can control up to two DC motors at a constant current of 1 2A 3 2A peak Two input signals IN1 and IN2 can be used to contr...

Страница 235: ...he range of DC 2 7 5 5V while the motor supply VM is limited to a maximum voltage of 15V DC The output current is rated up to 1 2A per channel or up to 3 2A for a short single pulse The motor driver p...

Страница 236: ...both supply lines Slide switch SWITCHES are components that control the open ness or closed ness of an electric circuit Just like the momentary buttons used in earlier circuits this type of switch can...

Страница 237: ...237...

Страница 238: ...238 Circuit Diagram...

Страница 239: ...239 Upload Code 1 Connect the REV4 Board to a USB port on your computer 2 Open the program in the code folder Circuit 21 or directly copy and paste the code below on the Ardunio IDE...

Страница 240: ...IN2 3 int STBY 4 int BIN1 5 int BIN2 6 int PWMA 10 enable pin 1 int PWMB 11 enable pin 2 D2 and D3 as a set D5 and D6 as a set D10 and D11 as enable pins for DC motors void setup int i for i 2 i 6 i A...

Страница 241: ...2 DC motor rotate CW for 1S and rotate CCW for 1S rotate CW front delay 1000 Stop back delay 1000 Stop delay 1000 left delay 1000 Stop delay 1000 right delay 1000 Stop delay 1000 void front digitalWr...

Страница 242: ...200 digitalWrite BIN1 HIGH digitalWrite BIN2 LOW analogWrite PWMB 200 void back digitalWrite STBY HIGH digitalWrite AIN1 LOW digitalWrite AIN2 HIGH analogWrite PWMA 200 digitalWrite BIN1 LOW digitalWr...

Страница 243: ...Write AIN2 LOW analogWrite PWMA 200 digitalWrite BIN1 LOW digitalWrite BIN2 HIGH analogWrite PWMB 200 void right digitalWrite STBY HIGH digitalWrite AIN1 LOW digitalWrite AIN2 HIGH analogWrite PWMA 20...

Страница 244: ...D3 as a set D5 and D6 as a set D10 and D11 as enable pins for DC motors void setup int i for i 2 i 6 i Ardunio motor driver module pinMode i OUTPUT set digital pins 2 3 4 5 6 as output pinMode 10 OUTP...

Страница 245: ...te BIN1 HIGH digitalWrite BIN2 LOW analogWrite PWMB 200 delay 1000 pause for 1S digitalWrite STBY LOW delay 1000 rotate CCW digitalWrite STBY HIGH digitalWrite AIN1 LOW digitalWrite AIN2 HIGH analogWr...

Страница 246: ...de 1 motor basics the motor will rotate forward for one second then stop for one second then go back for one second and stop for one second followed by turning left for 1S stop for 1S then turn right...

Страница 247: ...247...

Страница 248: ...f your project this circuit you ll control two motors and build your own light following robot You can use the light source to tell the robot in what direction to move or move straight What You Need G...

Страница 249: ...he photoelectric effect of semiconductor If the incident light is intense its resistance reduces if the incident light is weak the resistance increases Photo resistor is widely applied to various ligh...

Страница 250: ...250...

Страница 251: ...Code 1 Connect the REV4 Board to a USB port on your computer 2 Open the program in the code folder Circuit 22 or directly copy and paste the code below on the Ardunio IDE 3 Select UPLOAD to program t...

Страница 252: ...int PWMA 10 enable pin 1 int PWMB 11 enable pin 2 int Fspeed int Lspeed int Rspeed void setup Serial begin 9600 int i for i 2 i 6 i Ardunio motor driver module pinMode i OUTPUT set digital pins 2 3 4...

Страница 253: ...1 Serial print value1 Serial print Serial println value2 if value1 900 value2 900 if front distance is less than 10cm front if value1 900 value2 900 if front distance is less than 10cm left if value1...

Страница 254: ...than 10cm stop void front digitalWrite STBY HIGH digitalWrite AIN1 HIGH digitalWrite AIN2 LOW analogWrite PWMA 200 digitalWrite BIN1 HIGH digitalWrite BIN2 LOW analogWrite PWMB 200 void back digitalW...

Страница 255: ...gitalWrite BIN2 HIGH analogWrite PWMB 200 void stop digitalWrite STBY LOW void left digitalWrite STBY HIGH digitalWrite AIN1 HIGH digitalWrite AIN2 LOW analogWrite PWMA 200 digitalWrite BIN1 LOW digit...

Страница 256: ...alWrite BIN2 LOW analogWrite PWMB 200 What You Will See Start by flipping the switch to the ON position Hook it up and upload the code success the tank robot is walking with strong light under certain...

Страница 257: ...257 Both two photoresistors sense the light source the robot will go straight to follow the light illumination Shown below...

Страница 258: ...258...

Страница 259: ...ect this circuit you ll control two motors and build your own remote controlled roving robot You can use the remote controller to tell the robot in what direction to move and how far to move What You...

Страница 260: ...ectly output digital signal Infrared receiver has 3 pins When you use it connect VOUT to Analog pin GND to GND VCC to 5V VCC GND VOUT Remote Controller Infrared remote control is composed of infrared...

Страница 261: ...261 Below we have listed out each button value of keyestudio remote control for reference Hookup Guide Check out the circuit diagram and hookup table below to see how everything is connected...

Страница 262: ...262...

Страница 263: ...run this make sure that you have installed the IRremote h library or re install it if necessary Otherwise your code won t work 2 Connect the REV4 Board to a USB port on your computer 3 Open the progr...

Страница 264: ...g on1 0x00FF6897 unsigned long off1 0x00FF9867 int AIN1 2 int AIN2 3 int STBY 4 int BIN1 5 int BIN2 11 int PWMA 10 enable pin 1 int PWMB 6 enable pin 2 unsigned long advance1 0x00FF629D unsigned long...

Страница 265: ...2 3 4 5 6 as output pinMode 10 OUTPUT set digital pins 10 11 as output pinMode 11 OUTPUT pinMode LED1 OUTPUT irrecv enableIRIn Start the receiver void loop if irrecv decode results if results value ad...

Страница 266: ...alue off1 digitalWrite LED1 LOW irrecv resume Receive the next value void front digitalWrite STBY HIGH digitalWrite AIN1 HIGH digitalWrite AIN2 LOW analogWrite PWMA 200 digitalWrite BIN1 HIGH digitalW...

Страница 267: ...Write BIN1 LOW digitalWrite BIN2 HIGH analogWrite PWMB 200 void Stop digitalWrite STBY LOW void left digitalWrite STBY HIGH digitalWrite AIN1 HIGH digitalWrite AIN2 LOW analogWrite PWMA 200 digitalWri...

Страница 268: ...alWrite AIN1 LOW digitalWrite AIN2 HIGH analogWrite PWMA 200 digitalWrite BIN1 HIGH digitalWrite BIN2 LOW analogWrite PWMB 200 What You Will See Start by flipping the switch to the ON position Use rem...

Страница 269: ...269...

Страница 270: ...270 Circuit 24 Ultrasonic Ranging Robot About this circuit What You Need Gear Motor x 2 TB6612FNG Motor Driver x 1 TB6612FN Slide switch x 1 ultrasonic sensor x 1 Jumper wires x 25...

Страница 271: ...271 Hookup Guide Check out the circuit diagram and hookup table below to see how everything is connected...

Страница 272: ...272 Circuit Diagram...

Страница 273: ...t the REV4 Board to a USB port on your computer 2 Open the program in the code folder Circuit 24 or directly copy and paste the code below on the Ardunio IDE 3 Select UPLOAD to program the sketch on t...

Страница 274: ...in to D12 int pinEcho 9 define ultrasonic echo pin to D13 int Fspeed int Lspeed int Rspeed void setup Serial begin 9600 int i for i 2 i 6 i Ardunio motor driver module pinMode i OUTPUT set digital pin...

Страница 275: ...c emit HIGH voltage 10 s here at least 10 s delayMicroseconds 10 digitalWrite pinTrip LOW make ultrasonic emit LOW voltage float Fdistance pulseIn pinEcho HIGH read the time difference Fdistance Fdist...

Страница 276: ...n 10cm stop clear the output data delay 100 back backward 0 2 second delay 200 if Fspeed 25 if front distance is less than25cm stop left delay 200 clear the output data ask_pin_F read the front distan...

Страница 277: ...r than right speed left delay 400 front if Lspeed Rspeed if left speed is less than or equal to right speed front if Lspeed 10 Rspeed 10 if both left and right side distance are less than 10cm back go...

Страница 278: ...italWrite AIN2 LOW analogWrite PWMA 200 digitalWrite BIN1 HIGH digitalWrite BIN2 LOW analogWrite PWMB 200 void back digitalWrite STBY HIGH digitalWrite AIN1 LOW digitalWrite AIN2 HIGH analogWrite PWMA...

Страница 279: ...Y HIGH digitalWrite AIN1 HIGH digitalWrite AIN2 LOW analogWrite PWMA 200 digitalWrite BIN1 LOW digitalWrite BIN2 HIGH analogWrite PWMB 200 void right digitalWrite STBY HIGH digitalWrite AIN1 LOW digit...

Страница 280: ...obot that you will build uses a simple sensor to avoid obstacles Keep in mind that the ultrasonic distance sensor needs a clear path to avoid unwanted interruptions in your robot s movements Keep the...

Страница 281: ...n the switch is turned off the robot will sit still When the switch is turned on the robot will drive forward until it senses an object When it senses an object in its path it will reverse and then tu...

Страница 282: ...282...

Страница 283: ...283 Circuit 25 Object Following Robot About this circuit What You Need Gear Motor x 2 TB6612FNG Motor Driver x 1 TB6612FN Slide switch x 1 ultrasonic sensor x 1 Jumper wires x 25...

Страница 284: ...284 Hookup Guide Check out the circuit diagram and hookup table below to see how everything is connected...

Страница 285: ...285...

Страница 286: ...Code 1 Connect the REV4 Board to a USB port on your computer 2 Open the program in the code folder Circuit 25 or directly copy and paste the code below on the Ardunio IDE 3 Select UPLOAD to program t...

Страница 287: ...ting pin to D12 int pinEcho 9 define ultrasonic echo pin to D13 int Fspeed int Lspeed int Rspeed void setup Serial begin 9600 int i for i 2 i 6 i Ardunio motor driver module pinMode i OUTPUT set digit...

Страница 288: ...asonic emit HIGH voltage 10 s here at least 10 s delayMicroseconds 10 digitalWrite pinTrip LOW make ultrasonic emit LOW voltage float Fdistance pulseIn pinEcho HIGH read the time difference Fdistance...

Страница 289: ...if Fspeed 0 Fspeed 15 if front distance is less than 10cm back if Fspeed 15 Fspeed 20 if front distance is less than 10cm stop if Fspeed 20 Fspeed 40 if front distance is less than 10cm front if Fspe...

Страница 290: ...e AIN2 LOW analogWrite PWMA 200 digitalWrite BIN1 HIGH digitalWrite BIN2 LOW analogWrite PWMB 200 void back digitalWrite STBY HIGH digitalWrite AIN1 LOW digitalWrite AIN2 HIGH analogWrite PWMA 200 dig...

Страница 291: ...IGH digitalWrite AIN2 LOW analogWrite PWMA 200 digitalWrite BIN1 LOW digitalWrite BIN2 HIGH analogWrite PWMB 200 void right digitalWrite STBY HIGH digitalWrite AIN1 LOW digitalWrite AIN2 HIGH analogWr...

Страница 292: ...See When the switch is turned off the robot will sit still When the switch is turned on the robot will drive forward until it senses an object When it senses an object in its path it will follow an ob...

Страница 293: ...293...

Страница 294: ...company dedicated to open source hardware research and development production and marketing Keyestudio is a best selling brand owned by KEYES Corporation our product lines range from Arduino boards sh...

Страница 295: ...ww amazon de shops A39F7KX4U3W9JH ES Amazon storefront http www amazon de shops A39F7KX4U3W9JH IT Amazon storefront http www amazon de shops A39F7KX4U3W9JH US Amazon storefront http www amazon com sho...

Страница 296: ...296 Fennie keyestudio com Thank you in advance...

Отзывы: