An Arduino board is used to control electronics from a PC.
With simple programming the Arduino can be programmed and unhooked from the computer, while doing it's task.
With an Arduino it's easy to turn things on/off, reading sensors, controlling motors and more.
Digital pins to turn things on/off, or to read an on/off state
PWM pins to use for
analog purpose, and to communicate with PWM equipment.
Analog inputs to read potentiometers or sensors etc.
Digital pins Digital pins is managed by boolean data type
(true/false) or
(HIGH/LOW) .
A digital output pin has 5 volt DC when it's true, and 0 volt DC when it's false.
A digital input pin is given 5 volt DC to be true, and given 0 volt DC to be false.
PWM pins PWM pins is managed by integer data type
(timing) .
A PWM pin is used for remote control, motor control, servo motors and more.
Analog input pins Analog inputs is read into a
byte data type.
An analog input is used for potentiometers, sensors and more.
PWM and digital pins is initialized to be an input or an output.
Potentiometer analog input, LEDS digital output Variable potentiometer input changes tempo of digital outputs [Play] [Download video] Potentiometer analog input, LEDS digital output | Arduino IDE Sketch File (.pde)
//Potentiometer analog input, LEDS digital output
void setup (){
for (byte b=0 ;b<=12 ;b++){pinMode (b,OUTPUT );}
}
int curPin;
int sensorValue;
int pauseMs;
void loop (){
sensorValue=analogRead (1 );
pauseMs=4 +(sensorValue/10 );
curPin=curPin+1 ;if (curPin>13 ){curPin=0 ;};
digitalWrite (curPin,HIGH );delay (pauseMs*2 );
digitalWrite (curPin,LOW );//delay(pauseMs);
}
Arduino source HTML generated by Arduino PDE to HTM | Mini converter , mortenbs.com Connecting a potentiometer to the Arduino The outer pins is connected to ground and 5v plus . The middle pin is the analog out . Various scripts for Arduino Serial monitor, Analog-inputs | Arduino IDE Sketch File (.pde)
//SERIAL MONITOR ALL SIX ANALOG INPUTS
void setup (){
Serial .begin (9600 );
}
void loop (){
Serial .print ("0=" );Serial .print (analogRead (0 ));Serial .print (", " );
Serial .print ("1=" );Serial .print (analogRead (1 ));Serial .print (", " );
Serial .print ("2=" );Serial .print (analogRead (2 ));Serial .print (", " );
Serial .print ("3=" );Serial .print (analogRead (3 ));Serial .print (", " );
Serial .print ("4=" );Serial .print (analogRead (4 ));Serial .print (", " );
Serial .print ("5=" );Serial .print (analogRead (5 ));Serial .println ("." );
delay (100 );
}
Arduino source HTML generated by Arduino PDE to HTM | Mini converter , mortenbs.com Serial monitor, PWM-inputs | Arduino IDE Sketch File (.pde)
//SERIAL MONITOR PWM INPUTS
void setup (){
Serial .begin (9600);
pinMode (3,INPUT );pinMode (5,INPUT );pinMode (6,INPUT );
pinMode (9,INPUT );pinMode (10,INPUT );pinMode (11,INPUT );
}
int readPwm(byte aPin){
return (pulseIn (aPin,HIGH )/10)-100;
}
void loop (){
Serial .print ("3=" );Serial .print (readPwm(3));Serial .print (" " );
Serial .print ("5=" );Serial .print (readPwm(5));Serial .print (" " );
Serial .print ("6=" );Serial .print (readPwm(6));Serial .print (" " );
Serial .print ("9=" );Serial .print (readPwm(9));Serial .print (" " );
Serial .print ("10=" );Serial .print (readPwm(10));Serial .print (" " );
Serial .print ("11=" );Serial .print (readPwm(11));Serial .println ("." );
delay (10);
}
Arduino source HTML generated by Arduino PDE to HTM | Mini converter , mortenbs.com Test PWM-outputs | Arduino IDE Sketch File (.pde)
//TEST PWM OUTOUTS
void setup (){
pinMode (3 ,OUTPUT );pinMode (5 ,OUTPUT );pinMode (6 ,OUTPUT );
pinMode (9 ,OUTPUT );pinMode (10 ,OUTPUT );pinMode (11 ,OUTPUT );
}
byte n=0 ;
void loop (){
n=n+1 ;if (n>255 ){n=0 ;}
analogWrite (3 ,n);analogWrite (5 ,n);analogWrite (6 ,n);
analogWrite (9 ,n);analogWrite (10 ,n);analogWrite (11 ,n);
delay (10 );
}
Arduino source HTML generated by Arduino PDE to HTM | Mini converter , mortenbs.com Test Servo-outputs | Arduino IDE Sketch File (.pde)
//TEST SERVO OUTPUTS
#include <Servo .h>
Servo servo5;//servo on PIN 5
Servo servo6;//servo on PIN 6
byte aValue=0 ;
void setup (){
servo5.attach (5 );
servo6.attach (6 );
}
void loop (){
aValue=aValue+1 ;if (aValue>180 ){aValue=0 ;}
servo5.write (aValue);
servo6.write (aValue);
delay (30 );
}
Arduino source HTML generated by Arduino PDE to HTM | Mini converter , mortenbs.com See also Robots and robotics - Robots and robotics. Electronic circuits for robot, motor control and more… Small circuits - Small electronic circuits. Delayed power on circuit, Delayed power off circuit, A simple... LPT relay board circuits - LPT relay board circuits. Information about LPT, videos, links etc. Before we had the... Resistor - A resistor is used to lower the voltage in an electronic circuit. Resistor color values... Transistor - A transistor is by it self a small power inverter. NPN-transistors reacts to positive and... Videos - List of videos that are available on the mortenbs.com website. IT - IT/Technology. Various projects and information about computer technology and electronic... mortenbs.com