Advertisement
kartonman

neon startup

Sep 6th, 2021
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. //neon light startup
  2. //To be used the turn on the neon lights in a store or other facility that uses neon ligts. Or to turn
  3. //on any other neon light, such as a sign. Original flicker code modified by Gary Granai to adjust timing.
  4.  
  5. unsigned long starttime;
  6. unsigned long endtime;
  7.  
  8. #define flickeringLED 7
  9.  
  10. int max_count = 250; // counter for the flicker table
  11. int count;
  12. byte Flicker_table[] = { 10, 10, 20, 30, 30, 30, 40, 50, 60, 70, 80, 70, 70,
  13. 60, 60, 50, 50, 50, 60, 70, 80, 90, 100,
  14. 120, 140, 160, 240, 250, 100, 150, 250, 250, 140,
  15. 240, 230, 220, 100, 80, 70, 70, 70, 80, 80,
  16. 140, 130, 120, 110, 200, 210, 220, 220, 100, 90,
  17. 40, 30, 30, 30, 20, 10, 10
  18. };
  19. //**************************************************************
  20. void setup() {
  21. pinMode(flickeringLED, OUTPUT);
  22. }
  23.  
  24. //************************************************************
  25.  
  26. void loop() {
  27.  
  28. { starttime = millis();
  29. endtime = starttime;
  30. while ((endtime - starttime)<=10000)
  31. flicker1();
  32. endtime = millis();
  33. }
  34.  
  35. }
  36. //************************************************************
  37. void flicker1() {
  38.  
  39. for ( int i = 0; i <= 80; i++) { // This for loop runs untill the flicker table finishes
  40. analogWrite(flickeringLED, Flicker_table[count]);
  41. count++;
  42. if (count > max_count) {
  43. digitalWrite(flickeringLED, HIGH);
  44. }
  45. delay(40); // the delay for our flicker, make it faster to to make it flicker a little more violently
  46. break;}
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement