Advertisement
gabbyshimoni

generic LED tester

Feb 11th, 2020
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. /*
  2. תוכנית בדיקה לחיבור נורת לד כולל שינוי בהירות
  3. */
  4.  
  5. void setup() {
  6. Serial.begin(9600);
  7. }
  8.  
  9. void loop() {
  10. Serial.println("Test LED:");
  11. Serial.println("=========");
  12. Serial.print("Enter the pin number that the LED is connected to:");
  13. while (Serial.available() == 0);
  14. int ledPin = Serial.parseInt();
  15. Serial.println(ledPin);
  16.  
  17. pinMode(ledPin, OUTPUT);
  18.  
  19. Serial.println("Test LED Blink - 5 blinks, interval 1 second");
  20.  
  21. for (int i = 0; i < 5; i++) {
  22. digitalWrite(ledPin, HIGH);
  23. delay(1000);
  24. digitalWrite(ledPin, LOW);
  25. delay(1000);
  26. }
  27.  
  28. Serial.println("Test blink END");
  29. delay(2000);
  30.  
  31. if (ledPin == 3 || ledPin == 5 || ledPin == 6 || ledPin == 9 || ledPin == 10 || ledPin == 11) {
  32. Serial.println("Test LED brightness");
  33. for (int j = 0; j < 256; j += 5) {
  34. analogWrite(ledPin, j);
  35. delay(30);
  36. }
  37. for (int j = 255; j >= 0; j -= 5) {
  38. analogWrite(ledPin, j);
  39. delay(30);
  40. }
  41. }
  42. Serial.println("**********************************************");
  43. Serial.println("Test ended");
  44. Serial.println("If no blinks where viewed test you LED connections");
  45. Serial.println("If no change in brightness was seen, verify the the LED is connected to the correct pin,");
  46. Serial.println("have the right resistor size, not burnt");
  47. Serial.println();
  48. Serial.println();
  49. Serial.println();
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement