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);
}

code: [select]
const int threshold=1022

out 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

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums