You are on page 1of 18

User Name:

visitor2
Password: Monday55

123dcircuits.io

Microcontrollers
(Arduino )

Inputs
and Ou
tputs (
IO)

PWR IN

USB / Power
(to Computer)
RESET

SCL\SDA
(I2C Bus)

POWER
5V / 3.3V / GND

Digital I\O
PWM(3, 5, 6, 9, 10, 11)

Analog
INPUTS

What's
on-boa
rd

Serial
transmission

Quartz Crystal

Analog
Reference
(0 to 5v)
& Ground

Onboard
LED (pin 13)

Tx/Rx
LEDs

~ PWM I\O
(3, 5, 6, 9, 10, 11)

ATMEGA
Microcontroller

Hello world
LED ON
LED OFF
LED ON
LED OFF

// the setup function runs once when you


press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the
voltage level)

delay(1000);
digitalWrite(13, LOW);
making the
delay(1000);
}

// wait for a second


// turn the LED off by
voltage LOW
// wait for a second

Blink Code

// the setup function runs once when you


press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs forever
void loop() {
digitalWrite(13, HIGH);

// turn the LED on (HIGH is the voltage

delay(1000);
digitalWrite(13, LOW);

// wait for a second


// turn the LED off by making the voltage

level)
LOW
delay(1000);
}

// wait for a second

Servo Wave Code

#include <Servo.h>
Servo myservo;
int pos = 0;

// create servo object to control a servo


// a maximum of eight servo objects can be created
// variable to store the servo position

void setup()
{
myservo.attach(9);
// attaches the servo on pin 9 to the
servo object
Serial.begin(9600);
// set up Serial library at 9600 bps
Serial.println("Hello servo! Position is at "); // prints hello with ending line
break
Serial.println(pos);
// prints hello with ending line break
delay(3000);
// waits 15ms for the servo to reach the
position
}
void loop()
{
for(pos = 45; pos < 145; pos += 1)
// goes from 0 degrees to 180
degrees
{
// in steps of 1 degree
myservo.write(pos);
// tell servo to go to position in
variable 'pos'
Serial.print("Fwd servo is at! "); // prints hello with ending line break
Serial.println(pos);
// prints hello with ending line break
delay(500);
// waits 15ms for the servo to
reach the position
}
for(pos = 145; pos>=45; pos-= 1)
// goes from 180 degrees to 0
degrees
{
myservo.write(pos);
// tell servo to go to position in
variable 'pos'
Serial.print("Rev servo is at! ");
// prints hello with ending line
break
Serial.println(pos);
// prints hello with ending line break
delay(50);
// waits 15ms for the servo to

You might also like