Professional Documents
Culture Documents
MYRNA ANOT-CABRERA
TERMS USED IN ARDUINO
• Arduino - is an open-source electronics platform based on easy-to-
use hardware and software. It's intended for anyone making
interactive projects.
• Shields- are boards that can be plugged on top of the Arduino PCB
extending its capabilities.
Some Samples of Shields:
Wifi shield – for wireless comm
Motor shield – for dc motor control
rMP3 shield – play sounds/music and read/write data from SD cards.
PARTS OF ARDUINO
Starting clockwise from the top center:
Analog Reference pin (orange)
Digital Ground (light green)
Digital Pins 2-13 (green)
Digital Pins 0-1/Serial In/Out - TX/RX
(dark green) - These pins cannot be used
for digital i/o (digitalRead and digitalWrite)
if you are also using serial communication
(e.g. Serial.begin).
Reset Button - S1 (dark blue)
In-circuit Serial Programmer (blue-green)
Analog In Pins 0-5 (light blue)
Power and Ground Pins (power: orange,
grounds: light orange)
External Power Supply In (9-12VDC) - X1
(pink)
Toggles External Power and USB Power
(place jumper on two pins closest to
desired supply) - SV1 (purple)
In-system programming (ISP), also called In-Circuit Serial USB (used for uploading sketches to the
Programming (ICSP), is the ability of some programmable logic
devices, microcontrollers, and other embedded devices to be
board and for serial communication
programmed while installed in a complete system, rather than between the board and the computer; can
requiring the chip to be programmed prior to installing it into the be used to power the board) (yellow)
system
Arduino AT mega 328 specifications
Is your robot bumping into walls? This quickly solves that problem.
By attaching a ultrasonic rangefinder, the robot can find out if
it's too close to obstacles, and turn around to avoid collision.
Hardware Required
• Arduino Robot
• ultrasonic rangefinder
• cable to plug the Ultrasonic sensor
Instruction
• Connect the Ultrasonic ranger to TK1
• Fix the sensor to the front of the robot
• Upload the example, unplug USB and turn on power
• Put the robot on the floor
• The robot will move around, avoiding obstacles in front
of it
• If you want to change the detection range, in the code
below, find the line @@while (getDistance()<20)**, 20
here means 20cm; change it to another value to try out
other sensitivities.
• You can also change the robot speed, look at
motorWrite() for a hint on how to do that.
int sensorPin = M1; // pin is used by the sensor
}
void setup() {
// initialize the Robot, SD card, and display // return the distance in cm
Serial.begin(9600); float getDistance() {
Robot.begin(); // read the value from the sensor
Robot.beginTFT(); int sensorValue = Robot.analogRead(sensorPin
Robot.beginSD(); );
Robot.displayLogos(); //Convert the sensor input to cm.
float distance_cm = sensorValue*1.27;
// draw a face on the LCD screen return distance_cm;
setFace(true); }
}
// make a happy or sad face
void loop() { void setFace(boolean onOff) {
// If the robot is blocked, turn until free if(onOff) {
while(getDistance() < 40) { // If an obstacle is // if true show a happy face
less than 20cm away Robot.background(0, 0, 255);
setFace(false); //shows an unhappy face Robot.setCursor(44, 60);
Robot.motorsStop(); // stop the motors Robot.stroke(0, 255, 0);
delay(1000); // wait for a moment Robot.setTextSize(4);
Robot.turn(90); // turn to the right and try Robot.print(":)");
again }else{
setFace(true); // happy face // if false show an upset face
} Robot.background(255, 0, 0);
// if there are no objects in the way, keep Robot.setCursor(44, 60);
moving Robot.stroke(0, 255, 0);
Robot.motorsWrite(255, 255); Robot.setTextSize(4);
delay(100); Robot.print("X(");
} }
}
Assignment
Bring the following materials:
1 - Breadboard
4 - Red, green , yellow leds
Connecting wires
1 – 9 volts battery
Push button switch
2 – 10 kiloohms ½ watt resistor
16 –1000 ohms ½ w resistor
1 – arduino
1 - serial USB Cable
1 – laptop with Arduino software