How to Read the Monitor in the Er

Upload the following sketch to your Arduino. Afterward on, nosotros volition see exactly how information technology works.

/* Adafruit Arduino - Lesson 5. Serial Monitor */  int latchPin = v; int clockPin = six; int dataPin = four;  byte leds = 0;  void setup()  {   pinMode(latchPin, OUTPUT);   pinMode(dataPin, OUTPUT);     pinMode(clockPin, OUTPUT);   updateShiftRegister();   Serial.begin(9600);   while (! Series); // Wait untilSerial is ready - Leonardo   Serial.println("Enter LED Number 0 to 7 or 'ten' to clear"); }  void loop()  {   if (Series.available())   {     char ch = Serial.read();     if (ch >= '0' && ch <= '7')     {       int led = ch - '0';       bitSet(leds, led);       updateShiftRegister();       Serial.impress("Turned on LED ");       Serial.println(led);     }     if (ch == 'ten')     {       leds = 0;       updateShiftRegister();       Series.println("Cleared");     }   } }  void updateShiftRegister() {    digitalWrite(latchPin, Depression);    shiftOut(dataPin, clockPin, LSBFIRST, leds);    digitalWrite(latchPin, HIGH); }
/* Adafruit Arduino - Lesson 5. Serial Monitor */  int latchPin = v; int clockPin = 6; int dataPin = 4;  byte leds = 0;  void setup()  {   pinMode(latchPin, OUTPUT);   pinMode(dataPin, OUTPUT);     pinMode(clockPin, OUTPUT);   updateShiftRegister();   Serial.begin(9600);   while (! Serial); // Await untilSerial is ready - Leonardo   Serial.println("Enter LED Number 0 to seven or '10' to clear"); }  void loop()  {   if (Series.bachelor())   {     char ch = Series.read();     if (ch >= '0' && ch <= '7')     {       int led = ch - '0';       bitSet(leds, led);       updateShiftRegister();       Serial.print("Turned on LED ");       Series.println(led);     }     if (ch == 'x')     {       leds = 0;       updateShiftRegister();       Serial.println("Cleared");     }   } }  void updateShiftRegister() {    digitalWrite(latchPin, LOW);    shiftOut(dataPin, clockPin, LSBFIRST, leds);    digitalWrite(latchPin, HIGH); }

After yous have uploaded this sketch onto your Arduino, click on the right-most button on the toolbar in the Arduino IDE. The push is circled beneath.

learn_arduino_ide_serial_moniotor_button.jpg

The following window will open.

learn_arduino_serial_monitor_0.jpg

This window is called the Serial Monitor and information technology is function of the Arduino IDE software. Its task is to let you to both transport letters from your computer to an Arduino lath (over USB) and likewise to receive messages from the Arduino.

The message "Enter LED Number 0 to ix or 'x' to clear" has been sent past the Arduino, and information technology is telling us what commands nosotros can send to the Arduino which is either to transport the 'x' (to plough all the LEDs off) or the number of the LED you want to plow on (where 0 is the bottom LED, 1 is the adjacent one up right upwardly to 7 for the top LED).

Endeavour typing the following commands, into the top expanse of the Serial Monitor that is level with the 'Ship' button. Press 'Send', afterward typing each of these characters: x 0 3 5

Typing ten, will have no issue, if the LEDs are already all off, but as y'all enter each number, the respective LED should low-cal and you volition get a confirmation message from the Arduino lath, so that the Serial Monitor will appear every bit shown below.

learn_arduino_serial_monitor.jpg

Y'all tin meet that I am about to printing send after inbound 'x' again. Practise this and all the LEDs volition turn off.

This guide was first published on Dec 04, 2012. Information technology was last updated on December 04, 2012.

This folio (The Serial Monitor) was last updated on Mar 03, 2022.

Text editor powered by tinymce.

rothheak1999.blogspot.com

Source: https://learn.adafruit.com/adafruit-arduino-lesson-5-the-serial-monitor/the-serial-monitor

0 Response to "How to Read the Monitor in the Er"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel