![]() While(Serial.available()=0)//WHILE serial. Serial.println(msg1) //Ask for input from user/sensor While(Serial.available())//start a loop to print in "question" string THIS PRINTS THE "msg1" String 1 time each loop then breaks Serial.println(msg1) //print out initial "string" aka msg1 Serial.begin(9600) //intialize serial com at 9600 baud Int number //assign "number" for variable value later Referencing post #7 ^^^^ if i rewrite the same code as this then it prints perfectly with no double printing: again i'm just trying to understand why his codes are not working on my unit when i'm plain as day copying his code letter for letter It enters in 1 count command and then offers no more input commandsĪs per the serial.available syntax page and now it just infinitely loops the question without waiting for an input. While(Serial.available())//WHILE serial.avail do nothing and wait I'm not a master programmer or anything but i've played with c++ for a few years before compilers could be downloaded onto phones and MSDOS and shell systems were "the up and coming thing". Why is it printing : Serial.println(question) at the beginning twice? The loop function checks if the left or right button on the LCD Keypad Shield is pressed using the analogRead function. I'm making sure i don't have a bug in my atmel328 pic. WHY? IT has nothing to do with my serial.available if my Rewritten code functioned using it. When i use his exact code letter for letter i have a double print. THEN SHOWS SAID CODE FUNCTIONING IN THE SAME VIDEO IN VIDEO.Īrduino Tutorial 18: Reading Numbers from the Serial Monitor | Technology Tutorials () THERE ARE NO ERRORS IN HIS CODE IF IT'S WORKING IN HIS VIDEO! I'VE COPIED IT LETTER FOR LETTER IN THE VIDEO! HE LITTERALLY ZOOMS IN ON THE CODE FOR YOU TO COPY IT ALONG WITH HIM. HIS EXACT CODE ON MY SYSTEM PRODUCES A DOUBLE PRINT! HIS VIDEO SHOWS HIS CODE WORKING PERFECTLY! have you even seen paul mcwhorter vids? he shows his published codes functioning on camera while zoomed in on the code showing letter for letter each line so you can follow along. Number=Serial.parseInt() //now "number" is equal to the serial INPUT lineĭigitalWrite(Rled,HIGH) //turn on the ledĭigitalWrite(Rled,LOW) //turn off the led While(Serial.available()=0)//WHILE serial.avail do nothing and wait Serial.println(question) //Ask for input from user/sensor Void loop() //Ask first, wait, then read to get data from serial com Your tasks are just normal methods, called directly from the loop () method. PinMode(Rled,OUTPUT) //assing "Rled" D6 pin as an OUTPUT Introduction The instructable describes how to run multiple tasks on your Arduino without using an RTOS. ![]() Serial.begin(115200) //intialize serial com at 115200baud ![]() Int number //assign "random1" for variable value later rewriting it as this solved all my issues, BUT WHY DID I HAVE TO WRITE IT DIFFERENT THAN WHAT I WAS SHOWN ON THE LESSON? Shouldn't his code of worked no issues on my unit? 00001%ĪGAIN THE ISSUE IS WHY FOLLOWING HIS EXACT CODE DID NOT REPRODUCE THE SAME RESULTS HE SHOWED? since my first post wasn't clear enough i'm guessing. Serial.That still doesn't answer why my unit isn't doing what his is so it doesn't solve my issue by even. NumWhiteBlink = Serial.parseInt( ) //read user input Serial.println("how many times do you want to blink the WHITE LED ") //promt user input NumRedBlink = Serial.parseInt( ) //Read user input Serial.println("how many times do you want to blink the RED LED ") //promt user for input for the amoutn of blinks ![]() PinMode(whiteLEDPin, OUTPUT) //tell arduino that whiteLEDPin is an output pin PinMode(redLEDPin, OUTPUT) //tell arduino that redLEDPin is an output pin Serial.begin(115200) //serial port on code String WhiteMessage="the White LED is blinking" //Declaing a String variable String redMessage="the Red LED is blinking" //Declaring a String variable Int numWhiteBlink //number of times the white LED blinks Int numRedBlink //number of times the red LED blinks Int whiteOffTime=250 //this is the white LED off time Int whiteOnTime=250 //this is the white LED on time Int redOffTime=250 //this is the red LED off time Int redOnTime=250 //this is the red LED on time Int whiteLEDPin=10 //Declaring whiteLEDPin as an int, and set to pin 10 Int redLEDPin=9 //Declaring redLEDPin as an int, and set to pin 9 The actual problem is that the serial port will ask for the first setting then will skip the second and allow the 3rd to be set you can add the settings if you are quick but the serial port is not pausing waiting for all settings to be set. So I am unsure if there are some changes in the creation of the code with the newer version of the software. Hi I have been following Paul McWhorter on youtube and I am having some problems using a while loop so I can tell the code through the serial port the video was posted in 2014.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |