Photoswitch
hello everyone,
new forms.. bought arduino duemilanove act ligh or photoswitch. bought mini photocell. i need writting program. can me?
needs:
when light present no output
when dark full output.
needs checking @ least once every minute.
this got far.
const int sensorpin=0; // input photocell
const int ledpin=13; ///pin led
const int threshold=1022; //value of sensor
const int stop=0; //make never ending
void setup() {
//delcare ledpin output
//initialize serial communication
pinmode(ledpin, output);
serial.begin(9600);
}
//void why(){
//while(stop==0){loop();}
//}
void loop()
{
int sensorvalue = analogread(sensorpin);
if (sensorvalue>threshold){analogwrite(ledpin , sensorvalue);}
else { analogwrite(ledpin,0); }
// print analog value:
// serial.println(sensorvalue, dec);
}
new forms.. bought arduino duemilanove act ligh or photoswitch. bought mini photocell. i need writting program. can me?
needs:
when light present no output
when dark full output.
needs checking @ least once every minute.
this got far.
const int sensorpin=0; // input photocell
const int ledpin=13; ///pin led
const int threshold=1022; //value of sensor
const int stop=0; //make never ending
void setup() {
//delcare ledpin output
//initialize serial communication
pinmode(ledpin, output);
serial.begin(9600);
}
//void why(){
//while(stop==0){loop();}
//}
void loop()
{
int sensorvalue = analogread(sensorpin);
if (sensorvalue>threshold){analogwrite(ledpin , sensorvalue);}
else { analogwrite(ledpin,0); }
// print analog value:
// serial.println(sensorvalue, dec);
}
code: [select]
const int threshold=1022out of maximum value of 1023, that's pretty narrow range.
what "photocell", , how wired?
also, writing value "analogwrite" maximum range of 0..255 work, it's best right.
try looking @ "map".
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Photoswitch
arduino
Comments
Post a Comment