background image

keyestudio

www.keyestudio.cc

19

Click serial port monitor,Input R,LED 13 will blink once,PC will receive information from
Arduino: Hello World

After you choosing the right port

the experiment should be easy for you!

*******************************************************************************

Summary of Contents for ARDUINO maker learning kit

Page 1: ...keyestudio www keyestudio cc ARDUINO maker learning kit...

Page 2: ...ject 14 Analog temperature thermistor 62 Project 15 LM35 temperature sensor 67 Project 16 Temperature controlled cup 71 Project 17 DHT11 Temperature and Humidity Sensor 74 Project 18 Tilt switch 79 Pr...

Page 3: ...Y can learn electronics physics science knowledge and software programming while playing teachers can use it to achieve innovative teaching makers can use it for design verification of product prototy...

Page 4: ...mila you ll need to make sure that the board is configured to draw power from the USB connection The power source is selected with a jumper a small piece of plastic that fits onto two of the three pin...

Page 5: ...all from a list or specified location Advanced and click next Make sure that Search for the best driver in these locations is checked uncheck Search removable media check Include this location in the...

Page 6: ...keyestudio www keyestudio cc 4 6 Select your board You ll need to select the entry in the Tools Board menu that corresponds to your Arduino...

Page 7: ...al port 8 Upload the program Now simply click the Upload button in the environment Wait a few seconds you should see the RX and TX leds on the board flashing If the upload is successful the message Do...

Page 8: ...uage developed status in Java concept cross platform make a rapid growth of Arduino peripheral module and application The main reason to attract Artist to use Arduino is that they can quickly use all...

Page 9: ...ino cc en Main Software The downloaded file is arduino 1 0 zip a compressed folder to decompress it to the hard disk When 2560R3 Developing Board is connected to the Windows through the USB line Windo...

Page 10: ...e above to Arduino status select the model 2560 and port and then upload the code To wait a moment and the results came out then you will see the LED flashing at D13 of your 2560r3 board and the time...

Page 11: ...keyestudio www keyestudio cc 9 2 Component list No Product Name Quantity Picture 1 LED Red 10 2 LED Yellow 10 3 LED Blue 10 4 LED Green 10 5 LED RGB 2 6 220 resistor 20...

Page 12: ...keyestudio www keyestudio cc 10 7 100K resistor 20 8 1K resistor 20 9 4 7K resistor 20 10 47K resistor 20 11 10K resistor 20 12 101 ceramic capacitor 10 13 103 ceramic capacitor 10...

Page 13: ...cc 11 14 22 ceramic capacitor 10 15 104 ceramic capacitor 10 16 100uf16V electrolytic capacitor 10 17 10uf16V electrolytic capacitor 10 18 Button 6 19 Yellow round cap 3 20 Blue round cap 3 21 4007 di...

Page 14: ...tudio www keyestudio cc 12 23 8550 Transistor 2 24 1 digit 7 seg LED small 1 25 4 digit 7 seg LED small 1 26 LED Matrix small 1 27 5V Relay 1 28 MOS metal oxide semiconductor tube 1 29 Crystal oscilla...

Page 15: ...keyestudio www keyestudio cc 13 30 801S sensor 1 31 Highly sensitive MIC 1 32 Rotary encoder 1 33 DHT11 temperature and humidity 1 34 LM35 temperature sensor 1 35 Flame sensor 1 36 Ball tilt sensor 2...

Page 16: ...keyestudio www keyestudio cc 14 37 103 thermistor 2 38 Photoresistor 2 39 103 variable resistor 2 40 4N35 1 41 NE555P 1 42 DS1302 1 43 595 IC 2 44 Active buzzer 1...

Page 17: ...keyestudio www keyestudio cc 15 45 Passive buzzer 1 46 Pin header 1 16 1 47 Fan leaf 1 48 Fan motor 1 49 9G servo motor 1 50 1602 LCD 1 51 USB cable 100mm 1 52 Jumper Wire 1 65 1...

Page 18: ...ic light Project 5 LED chasing effect Project 6 Button controlled LED Project 7 Responder Project 8 Active buzzer Project 9 Passive buzzer Project 10 RGB LED Project 11 Analog value reading Project 12...

Page 19: ...e will begin with something simple In this project you only need an Arduino and a USB cable to start the Hello World experiment This is a communication test of your Arduino and PC also a primer projec...

Page 20: ...in OUTPUT initialize digital pin 13 as output When using I O ports on an Arduino this kind of set up is always needed void loop val Serial read read the instruction or character from PC to Arduino and...

Page 21: ...dio www keyestudio cc 19 Click serial port monitor Input R LED 13 will blink once PC will receive information from Arduino Hello World After you choosing the right port the experiment should be easy f...

Page 22: ...al pins rather than using LED13 which is soldered to the board Except an Arduino and an USB cable we will need extra parts as below Hardware required Red M5 LED 1 220 resistor 1 Breadboard 1 Breadboar...

Page 23: ...keyestudio www keyestudio cc 21 Connection for 2560 R3...

Page 24: ...digitalWrite ledPin HIGH set the LED on delay 1000 wait for a second digitalWrite ledPin LOW set the LED off delay 1000 wait for a second Result After downloading this program in the experiment you w...

Page 25: ...or 0V OFF The voltage or current is fed to the analog load the device that uses the power by repeated pulse sequence being ON or OFF Being on the current is fed to the load being off it s not With ade...

Page 26: ...l digital pin also one about potentiometer This time we will use a potentiometer to control the brightness of the LED Hardware required Potentiometer module 1 Red M5 LED 1 220 resistor Breadboard 1 Br...

Page 27: ...t will be displaying the analog value on the screen You can consider this as the analog value reading project adding the PWM analog value assigning part Below is a sample program for your reference in...

Page 28: ...tln val display value of val analogWrite ledpin val 4 turn on LED and set up brightness maximum output of PWM is 255 delay 10 wait for 0 01 second Result After downloading the program when we rotate t...

Page 29: ...kes and do a bit more complicated experiment traffic lights Actually these two experiments are similar While in this traffic lights experiment we use 3 LEDs with different color other than 1 LED Hardw...

Page 30: ...keyestudio www keyestudio cc 28 Connection for 2560 R3...

Page 31: ...ge int redled 10 initialize digital pin 8 int yellowled 7 initialize digital pin 7 int greenled 4 initialize digital pin 4 void setup pinMode redled OUTPUT set the pin with red LED as output pinMode y...

Page 32: ...5 second digitalWrite redled LOW turn off red LED Result When the uploading process is completed we can see traffic lights of our own design Note this circuit design is very similar with the one in LE...

Page 33: ...composed of colorful LEDs They are constantly changing to form various effects In this experiment we compile a program to simulate chase effect Hardware required Led 6 220 resistor 6 Breadboard jumpe...

Page 34: ...for the first LED int NUM 6 number of LEDs void setup for int i BASE i BASE NUM i pinMode i OUTPUT set I O pins as output void loop for int i BASE i BASE NUM i digitalWrite i LOW set I O pins as low...

Page 35: ...its OUTPUT function In this experiment we will try to use the input function which is to read the output value of device connecting to it We use 1 button and 1 LED using both input and output to give...

Page 36: ...keyestudio www keyestudio cc 34 Breadboard jumper wires Circuit connection Connection for R3 Connection for 2560 R3...

Page 37: ...age so statements of C language such as while switch etc can certainly be used for Arduino program When we press the button pin 7 will output high level We can program pin 11 to output high level and...

Page 38: ...riment is completed The simple principle of this experiment is widely used in a variety of circuit and electric appliances You can easily come across it in your every day life One typical example is w...

Page 39: ...keyestudio www keyestudio cc 37 Connection for 2560 R3...

Page 40: ...llow int green void setup pinMode redled OUTPUT pinMode yellowled OUTPUT pinMode greenled OUTPUT pinMode redpin INPUT pinMode yellowpin INPUT pinMode greenpin INPUT void loop repeatedly read pins for...

Page 41: ...e the code until green light is on end cycle when reset button is pressed while digitalRead restpin 1 digitalWrite redled LOW digitalWrite greenled HIGH digitalWrite yellowled LOW clear_led void clear...

Page 42: ...sound experiment is usually done with a buzzer or a speaker while buzzer is simpler and easier to use The buzzer we introduced here is a passive buzzer It cannot be actuated by itself but by external...

Page 43: ...keyestudio www keyestudio cc 41 Connection for 2560 R3...

Page 44: ...s finished you can begin programming Sample program Program is simple You control the buzzer by outputting high low level int buzzer 8 initialize digital IO pin that controls the buzzer void setup pin...

Page 45: ...roduce sound Normally the experiment is done with a buzzer or a speaker while buzzer is simpler and easier to use The buzzer we introduced here is a passive buzzer It cannot be actuated by itself but...

Page 46: ...keyestudio www keyestudio cc 44 Connection for 2560 R3...

Page 47: ...void loop unsigned char i j define variable while 1 for i 0 i 80 i output a frequency sound digitalWrite buzzer HIGH sound delay 1 delay1ms digitalWrite buzzer LOW not sound delay 1 ms delay for i 0...

Page 48: ...eyestudio www keyestudio cc 46 Project 10 RGB LED Introduction Tricolor principle to display various colors PWM controlling ports to display full color Can be driven directly by Arduino PWM interfaces...

Page 49: ...keyestudio www keyestudio cc 47 Hardware Required Arduino controller 1 USB cable 1 RGB LED 1 Circuit connection Connection for R3...

Page 50: ...keyestudio www keyestudio cc 48 Connection for 2560 R3...

Page 51: ...redpin 11 select the pin for the red LED int bluepin 10 select the pin for the blue LED int greenpin 9 select the pin for the green LED int val void setup pinMode redpin OUTPUT pinMode bluepin OUTPUT...

Page 52: ...we will begin the learning of analog I O interfaces On an Arduino there are 6 analog interfaces numbered from 0 to 5 These 6 interfaces can also be used as digital ones numbered as 14 19 After a brie...

Page 53: ...keyestudio www keyestudio cc 51 Connection circuit as below Connection for R3 Connection for 2560 R3...

Page 54: ...no and PC so the baud rate of the Arduino should match the the one in the PC s software set up Otherwise the display will be messy codes or no display at all In the lower right corner of the Arduino s...

Page 55: ...t to val Serial println val display val s value Result The sample program uses the built in LED connected to pin 13 Each time the device reads a value the LED blinks Below is the analog value it reads...

Page 56: ...istor whose resistance varies according to different incident light strength It s made based on the photoelectric effect of semiconductor If the incident light is intense its resistance reduces if the...

Page 57: ...t strenth changes So we will need to read the analog values We can refer to the PWM experiment replacing the potentiometer with photovaristor When there is change in light strength there will be corre...

Page 58: ...keyestudio www keyestudio cc 56 Connection for 2560 R3...

Page 59: ...nalogRead potpin read the analog value of the sensor and assign it to val Serial println val display the value of val analogWrite ledpin val turn on the LED and set up brightness maximum output value...

Page 60: ...to fluctuating level signal The signals are then input into the central processor and be dealt with accordingly Sensor connection The shorter lead of the receiving triode is for negative the other on...

Page 61: ...g buzzer Connect the controller board prototype board breadboard and USB cable according to the Arduino tutorial Connect the buzzer to digital pin 8 2 Connecting flame sensor Connect the sensor to ana...

Page 62: ...keyestudio www keyestudio cc 60 Connection for 2560 R3...

Page 63: ...the voltage So in the beginning of the program you can initialize voltage value i no fire value Then continuously read the analog voltage value j and obtain difference value k j i compare k with 0 6V...

Page 64: ...tely Project 14 Analog temperature thermistor Introduction Thermistor is a temperature measuring component base on the principle that a conductor changes in resistance with a change in its body temper...

Page 65: ...keyestudio www keyestudio cc 63 Circuit connection Connection for R3...

Page 66: ...keyestudio www keyestudio cc 64 Connection for 2560 R3...

Page 67: ...7 attach to the third pin of NE555 unsigned long duration the variable to store the length of the pulse void setup void setup Serial begin 9600 Set serial baud rate to 9600 bps void loop int val val...

Page 68: ...val DEC Print the value to serial port delay 100 Result Shown in pic 1 is data displayed by serial port monitor in room temperature After the temperature is changed thermistor wrapped and put into hot...

Page 69: ...keyestudio www keyestudio cc 67 Pic 2 Project 15 LM35 temperature sensor...

Page 70: ...emperature sensor It does not require other hardware You just need an analog port to make it work The difficulty lies in compiling the code to convert the analog value it reads to celsius temperature...

Page 71: ...keyestudio www keyestudio cc 69 Connection for 2560 R3 Sample program...

Page 72: ...e val analogRead 0 read the analog value of the sensor and assign it to val dat 125 val 8 temperature calculation formula Serial print Tep output and display characters beginning with Tep Serial print...

Page 73: ...circuit When the LM35 temperature sensor senses different temperature different LED will be turned on representing the temperature Hardware required Arduino controller 1 Breadboard 1 Breadboard jumper...

Page 74: ...keyestudio www keyestudio cc 72 Schematic diagram...

Page 75: ...vol 31 low temperature area and LED setup digitalWrite 13 HIGH digitalWrite 12 LOW digitalWrite 11 LOW else if vol 32 vol 40 digitalWrite 13 LOW digitalWrite 12 HIGH digitalWrite 11 LOW else if vol 4...

Page 76: ...high cost performance advantages Each DHT11 sensor features extremely accurate calibration data of humidity calibration chamber The calibration coefficients stored in the OTP program memory internal...

Page 77: ...keyestudio www keyestudio cc 75 Circuit connection Connection for R3...

Page 78: ...keyestudio www keyestudio cc 76 Connection for 2560 R3...

Page 79: ...RSION Serial println Serial println Type tstatus tHumidity tTemperature C void loop int chk Serial print DHT11 t chk DHT read DHT11_PIN READ DATA switch chk case DHTLIB_OK Serial print OK t break case...

Page 80: ...keyestudio www keyestudio cc 78 Result...

Page 81: ...keyestudio cc 79 Project 18 Tilt switch Introduction Tilt switch controls the ON and OFF of an LED Hardware required Ball switch 1 Led 1 220 resistor 1 Breadboard jumper wires Circuit connection Conn...

Page 82: ...keyestudio www keyestudio cc 80 Connection for 2560 R3...

Page 83: ...of the analog port is about 5V 1023 in binary The LED will be on When the other end of the switch is below horizontal position the switch is off The voltage of the analog port is about 0V 0 in binary...

Page 84: ...can be applied to relay control Experiment completed Thank you Project 19 Magical Light Cup Introduction Magical light cup module is a product developed by KEYES that can interact with ARDUINO The pr...

Page 85: ...keyestudio www keyestudio cc 83 Schematic diagram Circuit connection Connection for R3...

Page 86: ...5 int LedPinB 6 int ButtonPinA 7 int ButtonPinB 4 void setup pinMode LedPinA OUTPUT pinMode LedPinB OUTPUT pinMode ButtonPinA INPUT pinMode ButtonPinB INPUT void loop if digitalRead ButtonPinA HIGH R...

Page 87: ...sult Tilt the circuit to one side A light on B light out tilt to the other side A light out B light on Project 20 Vibration switch Introduction Vibration switch the correct name should be vibration se...

Page 88: ...keyestudio www keyestudio cc 86 Circuit connection Connection for R3 Connection for 2560 R3 Vibration switch Vibration switch...

Page 89: ...PUT pinMode SensorINPUT INPUT attachInterrupt 0 blink FALLING D2 as external interruption 0 when there is falling trigger and call blink function void loop if state 0 digitalWrite SensorLED HIGH delay...

Page 90: ...ill be on for 3 seconds and then be out Project 21 Sound control light Introduction In this experiment we use sound passing through MIC to control the on and off of the light Hardware required Potenti...

Page 91: ...keyestudio www keyestudio cc 89 Circuit connection Connection for R3...

Page 92: ...keyestudio www keyestudio cc 90 Connection for 2560 R3...

Page 93: ...weak and insensitive Instead of sound signal we blow air to the MIC Sample program int LEDpin 7 set pin for LED void setup Serial begin 9600 pinMode LEDpin OUTPUT void loop int Soundvalue analogRead...

Page 94: ...serial monitor For example the displayed data is less than 300 before blowing after blowing data is more than 300 Setup code if Soundvalue 300 control the on and off of the light the on time of the li...

Page 95: ...keyestudio www keyestudio cc 93...

Page 96: ...keyestudio www keyestudio cc 94...

Page 97: ...ng 0 1023 value Today we will use Arduino analog to make a 0 5V voltmeter Note in this experiment there is no complex protective circuit So please do not use more that 2 cells of AA batteries Besides...

Page 98: ...ly created integer variables V1 measurement range of voltage from analog port is 0 to 5V return value of 0 1023 float vol V1 5 0 1024 0 We convert V1 value into actual voltage value and store it into...

Page 99: ...normal if there is fluctuation between two voltage values because it is after all a low accuracy test Project 23 74HC595 Introduction To put it simply 74HC595 is a combination of 8 digit shifting regi...

Page 100: ...ol 8 LEDs Hardware required 74HC595 chip 1 Red M5 LED 4 Green M5 LED 4 220 resistor 8 Breadboard 1 Breadboard jumper wires Note for pin 13 OE port of 74HC595 it needs to be connected to GND Circuit co...

Page 101: ...ram int data 2 set pin 14 of 74HC595as data input pin SI int clock 5 set pin 11 of 74hc595 as clock pin SCK int latch 4 set pin 12 of 74hc595 as output latch RCK int ledState 0 const int ON HIGH const...

Page 102: ...applied on displays of electromagnetic oven full automatic washing machine water temperature display electronic clock etc It is necessary that we learn how it works LED segment display is a semicondu...

Page 103: ...segment is high the segment is on when the anode level of a certain segment is low the segment is off Common cathode 7 segment display Each segment of the display consists of an LED So when you use it...

Page 104: ...keyestudio www keyestudio cc 102 Connection for 2560 R3...

Page 105: ...ycling display number 0 9 The displaying time for each number is subject to the delay time the longer the delay time the longer the displaying time set the IO pin for each segment int a 7 set digital...

Page 106: ...other segments digitalWrite j LOW digitalWrite dp LOW turn off segment dp void digital_2 void display number 2 unsigned char j digitalWrite b HIGH digitalWrite a HIGH for j 9 j 11 j digitalWrite j HI...

Page 107: ...lWrite e LOW digitalWrite f HIGH digitalWrite g HIGH digitalWrite dp LOW void digital_6 void display number 6 unsigned char j for j 7 j 11 j digitalWrite j HIGH digitalWrite c HIGH digitalWrite dp LOW...

Page 108: ...in 4 11as output void loop while 1 digital_0 display number 0 delay 1000 wait for 1s digital_1 display number 1 delay 1000 wait for 1s digital_2 display number 2 delay 1000 wait for 1s digital_3 displ...

Page 109: ...for Current limiting resistor One is to connect one resistor for each anode 4 in totals for d1 d4 anode An advantage for this method is that it requires fewer resistors only 4 But it cannot maintain...

Page 110: ...ww keyestudio cc 108 For 4 digit displays there are 12 pins in total When you place the decimal point downward the pin on the lower left part is refer to as 1 the upper left part 12 Manual for LED seg...

Page 111: ...keyestudio www keyestudio cc 109 Connection for R3 Connection for 2560 R3...

Page 112: ...or anode int d4 9 int d3 10 int d2 11 int d1 12 set variable long n 1230 int x 100 int del 55 fine adjustment for clock void setup pinMode d1 OUTPUT pinMode d2 OUTPUT pinMode d3 OUTPUT pinMode d4 OUTP...

Page 113: ...GH break case 2 digitalWrite d1 HIGH digitalWrite d2 LOW digitalWrite d3 HIGH digitalWrite d4 HIGH break case 3 digitalWrite d1 HIGH digitalWrite d2 HIGH digitalWrite d3 LOW digitalWrite d4 HIGH break...

Page 114: ...te b 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 digi...

Page 115: ...gitalWrite a HIGH digitalWrite b LOW 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...

Page 116: ...H digitalWrite dp LOW void Num_9 digitalWrite a HIGH digitalWrite b HIGH digitalWrite c HIGH digitalWrite d HIGH digitalWrite e LOW digitalWrite f HIGH digitalWrite g HIGH digitalWrite dp LOW void Cle...

Page 117: ...break case 9 Num_9 break default Clear break void Display unsigned char x unsigned char Number take x as coordinate and display number WeiXuan x pickNumber Number delay 1 Clear clear the screen Resul...

Page 118: ...l range waterproof and numerous specifications LED dot matrix displays can meet the needs of different applications and thus have a broad development prospect This time we will conduct an LED dot matr...

Page 119: ...d set pin 9 to high level and pin 13 to low level If you want to light LEDs on the first row you should set pin 9 to high level and pins 13 3 4 10 6 11 15 and 16 to low level If you want to light the...

Page 120: ...keyestudio www keyestudio cc 118 Connection for 2560 R3...

Page 121: ...ing function clear_ digitalWrite x 2 HIGH digitalWrite y 10 LOW delay 1 void show_num void display function call point drawing function unsigned char i j data for i 0 i 8 i data Text i for j 0 j 8 j i...

Page 122: ...LCD module uses a compatible IC so their features are basically the same 1602LCD main parameters Display capacity 16 2 characters Chip operating voltage 4 5 5 5V Working current 2 0mA 5 0V Optimum wor...

Page 123: ...n command mode 4 RW pin is also very common in LCD It s a selecting pin for read write When the pin is in high level it s in read operation when it s in low level it s in write operation 5 E pin is al...

Page 124: ...keyestudio www keyestudio cc 122 Connection for R3 Connection for 2560 R3...

Page 125: ...value define all pins int i 0 for i DB 0 i DI i assign value for bus digitalWrite i value 01 for 1602 LCD it uses D7 D0 not D0 D7 for signal identification here it s used for signal inversion value 1...

Page 126: ...rief pause for LCD control LcdCommandWrite 0x38 select as 8 bit interface 2 line display 5x7 character size delay 64 LcdCommandWrite 0x38 select as 8 bit interface 2 line display 5x7 character size de...

Page 127: ...LcdDataWrite e LcdDataWrite LcdDataWrite t LcdDataWrite o delay 10 LcdCommandWrite 0xc0 1 set cursor position at second line second position delay 10 LcdDataWrite g LcdDataWrite e LcdDataWrite e LcdDa...

Page 128: ...e same delay 10 LcdCommandWrite 0x80 5 set cursor position at first line sixth position delay 10 LcdDataWrite t LcdDataWrite h LcdDataWrite e LcdDataWrite LcdDataWrite a LcdDataWrite d LcdDataWrite m...

Page 129: ...Connection for 2560 R3 After the connection upload below code to the controller board and see how it goes Sample code B int LCD1602_RS 12 int LCD1602_RW 11 int LCD1602_EN 10 int DB 6 7 8 9 char str1 W...

Page 130: ...for i DB 0 i 9 i digitalWrite i temp 0x80 temp 1 digitalWrite LCD1602_EN HIGH delayMicroseconds 1 digitalWrite LCD1602_EN LOW temp command 0x0f 4 for i DB 0 i 10 i digitalWrite i temp 0x80 temp 1 digi...

Page 131: ...mp 0x80 temp 1 digitalWrite LCD1602_EN HIGH delayMicroseconds 1 digitalWrite LCD1602_EN LOW void LCD_SET_XY int x int y int address if y 0 address 0x80 x else address 0xC0 x LCD_Command_Write address...

Page 132: ..._Command_Write 0x0c delay 50 LCD_Command_Write 0x80 delay 50 LCD_Command_Write 0x01 delay 50 void loop void LCD_Command_Write 0x01 delay 50 LCD_Write_String 3 0 str1 line 1 start at the fourth address...

Page 133: ...otate direction accordingly and drive the core less motor The gear then pass the force to the shaft The sensor will determine if it has reached the commanded position according to the feedback signal...

Page 134: ...eed a servomotor and several jumper wires Hardware required 9G servo motor 1 Breadboard jumper wire several Connection sample program There are two ways to control a servomotor with Arduino One is to...

Page 135: ...keyestudio www keyestudio cc 133 Connection for R3 Connection for 2560 R3...

Page 136: ...tor signal line int myangle initialize angle variable int pulsewidth initialize width variable int val void servopulse int servopin int myangle define a servo pulse function pulsewidth myangle 11 500...

Page 137: ...in servo function and some of its common statements 1 attach interface select pin for servo can only use pin 9 or 10 2 write angle used to control the rotate angle of the servo can set the angle amon...

Page 138: ...r one according to your liking or actual need Project 29 Rotary Encoder Introduction The rotary encoder can count the pulse outputting times during the process of its rotation in positive and reverse...

Page 139: ...keyestudio www keyestudio cc 137 Circuit connection Connection for uno R3...

Page 140: ...keyestudio www keyestudio cc 138 Connection for 2560 R3...

Page 141: ...rupt interruptB buttonState FALLING pinMode CLK INPUT digitalWrite 2 HIGH Pull High Restance pinMode DAT INPUT digitalWrite 3 HIGH Pull High Restance pinMode BUTTON INPUT digitalWrite 4 HIGH Pull High...

Page 142: ...tions 1 Expanding the control range for example when the control signal of the multicontact relay reaches a certain value it can form different contact ways At the same time switch on or off of multip...

Page 143: ...ated working voltage or coil will be burnt out due to high current e Release current Refers to the maximum current for the relay to gennerate release action When the suction state current reduces to a...

Page 144: ...keyestudio www keyestudio cc 142 Circuit connection Connection for R3...

Page 145: ...keyestudio www keyestudio cc 143 Connection for 2560 R3...

Page 146: ...lWrite relay HIGH relay conducted Delay 1000 DigitalWrite relay LOW relay switch Delay 1000 Result You can have different ways to do the conduction and disconnection process This is one way for your r...

Page 147: ...ear month day hour minute second and week It supports backup battery for continuous charging You can conviniently connect it to Arduino with three data cables Hardware required Arduino board x1 USB ca...

Page 148: ...keyestudio www keyestudio cc 146 Connection for 2560 R3 Sample program...

Page 149: ...appropriate digital I O pin connections uint8_t CE_PIN 5 uint8_t IO_PIN 6 uint8_t SCLK_PIN 7 Create buffers char buf 50 char day 10 Create a DS1302 object DS1302 rtc CE_PIN IO_PIN SCLK_PIN void print...

Page 150: ...date t hr t min t sec Print the formatted string to serial so we can see the time Serial println buf void setup Serial begin 9600 Initialize a new chip by turning off write protection and clearing th...

Page 151: ...debugger you can see current time If the time needs adjustment you only need to input current date and time in the com port and seperate with a comma Format as Year month day minute second week Week n...

Page 152: ...control the rotation of the motor When D3 is input with high level voltage MOS tube DS is conducted motor begins to rotate When D3 is input with low level voltage MOS tube DS is disconnected motor sto...

Page 153: ...dio cc 151 Circuit connection Connection for R3 Connection for 2560 R3 Sample program the setup function runs once when you press reset or power the board void setup initialize digital pin 33 as an ou...

Page 154: ...electrode is connected to digital port 3 s electrode to GND and digital port 3 output is HIGH Vgs is 5V meeting the requirement DS is conducted motor rotates When digital port output is LOW Vgs is 0...

Page 155: ...keyestudio www keyestudio cc 153 Circuit connection Connection for R3...

Page 156: ...keyestudio www keyestudio cc 154 Connection for 2560 R3...

Page 157: ...155 Sample program int Optocoupler 8 void setup pinMode Optocoupler OUTPUT void loop digitalWrite Optocoupler LOW delay 1000 digitalWrite Optocoupler HIGH delay 1000 Result Red light blinks on for 1...

Page 158: ...lse generators and oscillators In this experiment we will use the Uno board to test the frequencies of square waves generated by the 555 oscillating circuit and show them on a serial monitor Hardware...

Page 159: ...0 and 1 decided by the input electrical level Pin 4 RESET output low level when supplied a low voltage level Pin 5 CONTROL VOLTAGE changing the upper and lower level trigger values Pin 6 THRESHOLD the...

Page 160: ...keyestudio www keyestudio cc 158 Connection for 2560 R3...

Page 161: ...e length of the pulse void setup pinMode pin INPUT set the pin as an input Serial begin 9600 start serial port at 9600 bps void loop duration pulseIn pin HIGH Reads a pulse on pin Serial print duratio...

Page 162: ...esult Burn the program into Uno board After burning the program open the serial monitor and you will see the picture shown below If you rotate the potentiometer the length of the pulse in microsecond...

Reviews: