mortenbs.com

Arduino Duemilanove

Shown 163 times
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. It is also possible to control an Arduino directly from a computer through USB-cable.

Home \ Computers, games and robotics \ Arduino Duemilanove
Three years ago

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.
It is also possible to control an Arduino directly from a computer through USB-cable.

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 gives 5 volt DC when true, and 0 volt DC when false.
A digital input pin is given ~3-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 as 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.
To protect the Arduino, all input pins should be given only 5 volt from the device itself.
If inputs is given above 5 volt it may damage the device.
Also if and output pin is connected to ground, the pin may be destroyed.

Connecting a potentiometer to the Arduino

The outer pins is connected to ground and 5 volt DC.
The middle pin is the analog out.


Potentiometer analog input, LEDS digital output

//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);




Various scripts for Arduino


Serial monitor, Analog-inputs

//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);




Test PWM-outputs

//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);




Test Servo-outputs

//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);
}  




Pages in Arduino Duemilanove

 


Related pages

1 Computers, games and robotics  (16) 

Other pages in Computers, games and robotics

01 LPT relay boards with Delphi  Thirteen days ago
02 Crysis SandBox  (2)  A month and a half ago
03 Large 4WD robot vehicle 24 VDC for outdoor use  A year ago
04 Commodore 64  (2)  Two years ago
05 Need For Speed: World  (5)  Two years ago
06 Delphi programming  (3)  Three years ago
07 Small circuits  Three years ago
08 BLUDK Robotic Vehicles  Four years ago
09 DC Motor Control  Four years ago
10 Transistor  Four years ago
More...


Copyright 2008-2014, mortenbs.com, All Rights Reserved. Loaded in 0.15 sec.