Thursday 14 January 2010

The dial

So far, with my baby steps, i have managed to get my potentiometer (the dial) working without the real time clock.

The thing for this set of code, is programming the potentiometer to have sections or divides. The potentiometer ranges from 0-1023. If i wanted 7 sections, i would divide 1023/7= 146. (These sections could be allocated alarm times.)

This is the code so far:

const int ledred = 10; // the number of the red pin

void setup() {
Serial.begin(9600);
}

void loop() {
// read the analog input into a variable:
int analogValue = analogRead(0);
// print the result:
Serial.println(analogValue/146);
// display the pot values in 7 different sections
delay(1000);

if (analogValue/146 == 1) { //if the pot value divided by 7 and is = 1 then...
digitalWrite (ledred, HIGH); // flash the led every half sec
delay(500);
digitalWrite (ledred, LOW);
delay(500);
} }

I am still working at combining it with my real time clock.

No comments:

Post a Comment