LED ON OFF For One Sec/Count and Display on the Attached Serial Monitor

Turns on an LED on for one second, then off for one second, repeatedly. Counts and displays the count on the attached serial monitor

  1. /* Sketch uses 13,808 bytes (12%) of program storage space. Maximum is 108,000 bytes.
  2.    Global variables use 2,592 bytes of dynamic memory.
  3.   Turns on an LED on for one second, then off for one second, repeatedly.
  4.   Counts and displays the count on the attached serial monitor
  5.  */
  6. int n = 0;
  7. void setup() {                
  8.   // initialize the digital pin as an output.
  9.   pinMode(33, OUTPUT);
  10.   // Initialize virtual COM over USB on Maple Mini
  11.   Serial.begin(9600);  // BAUD has no effect on USB serial: placeholder for physical UART
  12.   // wait for serial monitor to be connected.
  13.   while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
  14.   {
  15.     digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off
  16.     delay(100);         // fast blink
  17.   }
  18.   Serial.println("Blink LED & count Demo");
  19. }
  20. void loop() {
  21.   digitalWrite(33, HIGH);   // set the LED on
  22.   //delay(5);              // wait for a second
  23.   digitalWrite(33, LOW);    // set the LED off
  24.   Serial.print("Loop #: ");
  25.   n++;
  26.   Serial.println(n);
  27.    
  28.   //delay(5);              // wait
  29. }


Learn More :