Senzorul de lumina TSL235R este o componenta care sesizeaza nivelul de iluminare al mediului extrem de precis (etalonat). Mai exact, acest senzor furnizeaza un semnal dreptunghiular a carui frecventa variaza cu intensitatea luminoasa receptionata de senzor (masurata in uW cm 2). Circuitul de pe placa adauga un condensator de filtrare care face ca senzorul sa fie foarte precis, interferentele cauzate de alimentare fiind eliminate. volatile unsigned long cnt 0; unsigned long oldcnt 0; unsigned long t 0; unsigned long last; void irq1() { cnt++; } void setup() { Serial.begin(9600); Serial.println( START ); pinMode(2, INPUT); digitalWrite(2, HIGH); attachInterrupt(0, irq1, RISING); } void loop() { if (millis() – last 1000) { last millis(); t cnt; unsigned long hz t – oldcnt; Serial.print( FREQ: ); Serial.print(hz); Serial.print( t ); Serial.print((hz+50) 100); Serial.println( mW m2 ); oldcnt t; } } Cod Arduino FILE: demo01.pde AUTHOR: Rob Tillaart DATE: 2011 05 16 PURPOSE: prototype TSL235R monitoring Digital Pin layout ARDUINO 2 IRQ 0 – to TSL235R PIN 1 – GND PIN 2 – VDD – 5V PIN 3 – SIGNAL volatile unsigned long cnt 0; unsigned long oldcnt 0; unsigned long t 0; unsigned long last; void irq1() { cnt++; } SETUP void setup() { Serial.begin(115200); Serial.println( START ); pinMode(2, INPUT); digitalWrite(2, HIGH); attachInterrupt(0, irq1, RISING); } MAIN LOOP void loop() { if (millis() – last 1000) { last millis(); t cnt; unsigned long hz t – oldcnt; Serial.print( FREQ: ); Serial.print(hz); Serial.print( t ); Serial.print((hz+50) 100); +50 rounding last digit Serial.println( mW m2 ); oldcnt t; } } END OF FILE Tutorial Arduino 1 Tutorial Arduino 2 Datasheet (PDF)
Related products
Accelerometru
Accelerometru
RoboFun