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

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

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

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

No comments:

Post a Comment