150 likes | 364 Views
Embedded. Sumo 1T4 – 1T5 UTRA. What is Arduino?. Image Source: http ://arduino.cc/en/uploads/Main/ArduinoUno_r2_front450px.jpg. Arduino is an open-source electronics platform based on easy-to-use hardware and software. It's intended for anyone making interactive projects . - arduino.cc.
E N D
Embedded Sumo 1T4 – 1T5 UTRA
What is Arduino? Image Source: http://arduino.cc/en/uploads/Main/ArduinoUno_r2_front450px.jpg
Arduino is an open-source electronics platform based on easy-to-use hardware and software. It's intended for anyone making interactive projects. - arduino.cc Image Source: http://arduino.cc/en/uploads/Main/ArduinoDiecimilaComponents.jpg
Micro-controller: ATMega328-PU Image Source: http://d1gsvnjtkwr6dd.cloudfront.net/large/IC-ATMEGA328-PU_LRG.jpg
Aruidno IDE • C-like programming language • One-button upload • Come with example code
Select board Select Port Setup the IDE Port number can be found in “Device Manager” from “Control Panel”
/* Blink Turns on an LED on for one second, then off for one second, repeatedly. Most Arduinos have an on-board LED you can control. On the Uno and Leonardo, it is attached to digital pin 13. If you're unsure what pin the on-board LED is connected to on your Arduino model, check the documentation at http://arduino.cc This example code is in the public domain. modified 8 May 2014 by Scott Fitzgerald */ Example: Blinking LED
voidsetup(){ pinMode(13, OUTPUT); } voidloop() { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); } Example: Blinking LED
voidsetup(){ … } This function runs only once after boot-up or after you pressed the reset button. Hence the name “setup”. This function sets pin 13 as “output”, meaning you can set it to either “high” (5V) or “low” (0V). pinMode(13, OUTPUT); voidloop() { … } Example: Blinking LED This function runs over and over again forever.
This command turns the LED on (by making a 5V output). digitalWrite(13, HIGH); delay(1000); Sleep for 1 second. The unit for this function is millisecond (ms) and 1000 ms = 1s. Example: Blinking LED digitalWrite(13, LOW); This command turns the LED off (by making the output 0V, which is the same as ground).
voidsetup(){ pinMode(13, OUTPUT); } voidloop() { digitalWrite(13, HIGH); // LED on for 1 second delay(1000); digitalWrite(13, LOW); // LED off for 1 second delay(1000); } // repeat (back to the beginning of loop) Example: Blinking LED
voidsetup(){ Serial.begin(9600); } voidloop() { intsensorValue=analogRead(A0); Serial.println(sensorValue); delay(1000); } // repeat (back to the beginning of loop) Example: Analog & Serial
This command starts the serial communication between Arduino and the host PC at a specific baud rate. In this case, 9600. Serial.begin(9600); analogRead(A0); This command reads the voltage input at A0 and translate the number into a value between 0 and 1023. Example: Analog & Serial Serial.println(sensorValue); This command prints the value of the variable to the serial terminal in the Arduino IDE.
Click to open the serial terminal Inputs (from PC to Arduino) Outputs (from Arduino to PC) Serial Terminal Select the correct baud rate