Step 7Arduino program
We used an Arduino development board, as we have been playing around with them a bit for various projects.
Initially download and install the arduino software, which is available for; Windows, Mac OS X, Linux (32bit) and Linux (AMD 64bit).
After installing we used the following code:
(download the .pde file below)
/*
opening 'n' version 1.2
3 sets of 2 led's fadding from one to other via pot
*/
int ledPin1a = 11; //led 1 a
int ledPin1b = 10; // led 1 b
int ledPin2a = 9; //led 2 a
int ledPin2b = 6; // led 2 b
int ledPin3a = 5; // led 3 a
int ledPin3b = 3; //led 3 b
int PotPin1 = 1; //set variable to value of analog pin 1
int PotPin2 = 2; //set variable to value of analog pin 2
int PotPin3 = 3; //set variable to value of analog pin 3
int value1 = 0;
int value2 = 0;
int value3 = 0;
int ledValue1a = 0;
int ledValue1b = 0;
int ledValue2a = 0;
int ledValue2b = 0;
int ledValue3a = 0;
int ledValue3b = 0;
void setup()
{
pinMode(ledPin1a, OUTPUT);
pinMode(ledPin1b, OUTPUT);
pinMode(ledPin2a, OUTPUT);
pinMode(ledPin2b, OUTPUT);
pinMode(ledPin3a, OUTPUT);
pinMode(ledPin3b, OUTPUT);
Serial.begin(9600);
value1 = analogRead(1);
value2 = analogRead(2);
value3 = analogRead(3);
}
void loop()
{
value1 = analogRead(PotPin1); //read value of PotPin1
ledValue1a = value1 /=4;
ledValue1b = 255 - ledValue1a;
analogWrite(ledPin1a, ledValue1a);
analogWrite(ledPin1b, ledValue1b);
value2 = analogRead(PotPin2); //read value of PotPin2
ledValue2a = value2 /=4;
ledValue2b = 255 - ledValue2a;
analogWrite(ledPin2a, ledValue2a);
analogWrite(ledPin2b, ledValue2b);
value3 = analogRead(PotPin3); //read value of PotPin3
ledValue3a = value3 /=4;
ledValue3b = 255 - ledValue3a;
analogWrite(ledPin3a, ledValue3a);
analogWrite(ledPin3b, ledValue3b);
Serial.print(ledValue1a);
}
//works nice, straight fade, one high other low.
This then needs to be uploaded via USB to the arduino board. Having the serial.print function enabled means that it is possible to see the value being created by pot 1 which is good for testing and debugging.
Having completed upload and testing you then unplug the USB and move the jumpers to enable the arduino to use a external power supply rather than the USB.
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|




















































