Advertisement
icstation

The code for Light Sensor LED Brightness Control System

Dec 8th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. The code for Light Sensor LED Brightness Control System with ATMEGA3
  2. http://www.instructables.com/id/Light-Sensor-LED-Brightness-Control-System-for-Ard/
  3. 1.ICStation UNO R3 with USB compatible with Arduino
  4. http://www.icstation.com/product_info.php?products_id=3516
  5. 2.Bread board
  6. http://www.icstation.com/product_info.php?products_id=1450
  7. 3.Highlight LED light emitting diode
  8. http://www.icstation.com/product_info.php?products_id=3226
  9. 4.Analog light sensor
  10. 5.Hard jumper wire
  11. 6.4 PCS jumper wire
  12. 7. 5 Voltage DC power supply
  13. 8.3 PCS of pins
  14. 9.3P DuPont line
  15.  
  16.  
  17. Specific source program as follows:
  18. int _ABVAR_1_Bright;
  19.  
  20. void setup()
  21.  
  22. {   
  23.  
  24. _ABVAR_1_Bright = 0;
  25.  
  26.   Serial.begin(9600);
  27.  
  28. }
  29.  
  30. void loop()
  31.  
  32. {   
  33.  
  34. Serial.print( analogRead(A0) );  
  35.  
  36.  Serial.println("");  
  37.  
  38.  _ABVAR_1_Bright = analogRead(A0) ;   
  39.  
  40. analogWrite(3, map ( _ABVAR_1_Bright , 50 , 900 , 0 , 255 ) );
  41.  
  42. if (( ( _ABVAR_1_Bright ) < ( 50 ) ))  
  43.  
  44.  {
  45.  
  46. analogWrite(3, 0);   
  47.  
  48. }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement