Shown 103 times
Arduino source code examples, Arduino projects and circuits, robotic projects and more. Use the Arduino to control electronics from your PC. With simple programming the Arduino device can also be programmed and disconnected from the PC, while it is doing its task. It is easy to use the Arduino.

Home \ Robotics \ Arduino

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... 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(){

Various scripts for Arduino

Serial monitor, Analog-inputs


void setup(){                

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(", ");

Test PWM-outputs


void setup(){                

byte n=0;

void loop(){

Test Servo-outputs


#include <Servo.h> 

Servo servo5;//servo on PIN 5
Servo servo6;//servo on PIN 6
byte aValue=0;

void setup(){

void loop(){

Related pages

1 Robotics  (10) 

Other pages in Robotics

1 Robotic vehicle, 24 VDC, 2x400W 22A motors  A year ago
2 Old 7v robotic vehicle  A year ago
3 Transistor 
4 Small circuits 
5 Resistor 
6 Robotic vehicles by B. Laursen  Four years ago
7 LPT relay-board circuits  Four years ago
8 DC Motor Control 

No content

Copyright 2008-2014,, All Rights Reserved. Loaded in 0.12 sec.