Arduino (Emman) PDF
Arduino (Emman) PDF
ATmega328/Main IC - This is
the brain of the board in which
the program is stored.
Digital I/O Pins - They are used to either sense the outside world (input) or control
lights, sounds, or motors (output).
Analog Pins - These pins can read the signal from an analog sensor (like a
temperature sensor) and convert it into a digital value that we can read.
Reset Button - This button will reset the code loaded into the board. This button is
useful when the board hangs up, pressing this button will take the entire board into
an initial state.
USB Interface - This interface is used to connect the board with the computer and to
upload the Arduino sketches (Arduino Program is called a Sketch).
DC Power Jack - This is used to power up the board with a power supply.
Power LED - This is a power LED that lights up when the board is connected with
the power source.
3.3V - This pin is used to supply 3.3V power to your projects. Positive Terminal
Built-in LEDs - The LEDS indicate that there is power, and if your Arduino is
sending or receiving data
GND(Ground) - Users can integrate any of these pins to ground their circuit.
Negative Terminals
Voltage Regulator - The voltage regulator converts power plugged into the power
port (described below) into the 5 volts and 1 amp standard used by the Arduino. BE
CAREFUL! This component gets very hot. Controls the amount of voltage that is let
into the arduino board.
SPI - The SPI stands for Serial Peripheral Interface. Four Pins 10(SS), 11(MOSI),
12(MISO), 13(SCK) are used for this communication.
TX/RX - Pins TX and RX are used for serial communication. The TX is a transmit pin
used to transmit the serial data while RX is a receive pin used to receive serial data.
Breadboard - Has tiny holes on it that are used to insert the wires
of the electronic components, such as LED, resistor, etc.
LED (Bright White, Green, Red, Yellow, Blue, and RGB) - stands
for Light Emitting Diode, which is defined as a semiconductor
light source. The Shorter pin of the LED is Negative while the
Longer pin is positive. The RGB colors are generated by adjusting
the brightness of each of the three colors by using the PWM pin.
Wooden base that can be easily assembled - used to assemble the Arduino
board and Breadboard on its base. (Sorry no Picture found).
Jump wires - simply wires that have connector pins at each
end, allowing them to be used to connect two points to each
other without soldering.
(40 x 1) Male Strip pins - a single row male pin consisting of 40 pin
headers connected to it.
Red, Blue, and Green Transparent Gels - colored gels act as a filter for the
sensors, which allows the specific colored light to pass through that gel. (Sorry no
pictures found)
USB Cable - Universal Serial Bus is a cable that is used to connect the
Arduino board with the computer.
int redlight=5; = Naming the pin so the code will understand and function well.
void setup(){ = a function created at the beginning of the program, between the
initialization of the variable and the void loop.
delay(4000); = Allows you to pause the execution of your Arduino program for a
specified period.
if(digitalRead(2)== HIGH) = Reads the value from a specified digital pin , either
HIGH or LOW. Reads the button voltage (high = not pressed, low= pressed).
{digitalWrite(12,HIGH);}
else
{digitalWrite(12,LOW);} = Tests a condition, then returns a value based on the
result of that condition.
Serial.begin (9600) ; = sets the baud rate for serial data communication. The
baud rate signifies the data rate in bits per second. The default baud rate in
Arduino is 9600 bps (bits per second).
delayMicroseconds (1000) ; = Pauses the program for the amount of time (in
microseconds) specified by the parameter.
SINGLE LIGHT
int redlight=5;
void setup(){
pinMode(redlight,OUTPUT);
}
void loop(){
digitalWrite(redlight,HIGH);
delay(4000);
digitalWrite(redlight,LOW);
delay(3000);
}
TRAFFIC LIGHT
//create the variables and assign the pins
void setup() {
// put your setup code here to run once:
void loop() {
// put your main code here to run repeatedly:
// SET INSTRUCTIONS CODE INSTRUCTION
// turn on led and turn off yellow and green lights- TURN ON RED STOP BASED
ON TRAFFICLIGHTS
digitalWrite(REDLIGHT,HIGH);
digitalWrite(YELLOWLIGHT,LOW);
digitalWrite(GREENLIGHT,LOW);
delay(5000);
// turn on RED and YELLOW led and turn off green lights- TURN ON RED THEN
YELLOW READY BASED ON TRAFFIC LIGHTS
digitalWrite(REDLIGHT,HIGH);
digitalWrite(YELLOWLIGHT,HIGH);
digitalWrite(GREENLIGHT,LOW);
delay(2000);
//turn on GREEN and turn off YELLOW and RED lights- TURN ON GREEN LED
MEANING GO ON TRAFFIC LIGHTS
digitalWrite(REDLIGHT,LOW);
digitalWrite(YELLOWLIGHT,LOW);
digitalWrite(GREENLIGHT,HIGH);
delay(5000);
//turn on YELLOW led and turn off GREEN and RED lights- TURN ON YELLOW
BASED ON TRAFFIC LIGHTS
digitalWrite(REDLIGHT,LOW);
digitalWrite(YELLOW,HIGH);
digitalWrite(GREENLIGHT,LOW);
delay(2000);
}
void loop(){
if(digitalRead(2)== HIGH)
{digitalWrite(12,HIGH);}
else
{digitalWrite(12,LOW);}
}
PIEZO BUZZER
int buzzer=6;
void setup()
{
pinMode(buzzer,OUTPUT);
}
void loop()
{
tone(buzzer,289);
delay(3000);
tone(buzzer,320);
delay(3000);
tone(buzzer,198);
delay(3000);
}
SERVO MOTOR
#include <Servo.h>
int servoPin = A1;
Servo Servo1;
void setup() {
Servo1.attach(servoPin);
}
void loop(){
Servo1.write(0);
delay(1000);
Servo1.write(90);
delay(1000);
Servo1.write(180);
delay(1000);
}
ULTRASONIC SENSOR
const int trig = 9;
const int echo = 10;
int duration = 0;
int distance = 0;
void setup () {
pinMode (trig , OUTPUT) ;
pinMode (echo, INPUT) :
Serial. begin (9600) ;
}
void loop () {
digitalWrite (trig, HIGH) ;
delayMicroseconds (1000) ;
digitalWrite(trig, LOW);
duration = pulseIn (echo , HIGH)
distance = (duration/2) / 29.1 ;
Serial.println (distance);
}