BLOG > Tutorial 6 for Arduino: Serial Comm and Processing

This tutorial was featured on the official Arduino blog on 3/9/2011

The next four episodes are all about communicating between the Arduino and other devices.  In this video, we’ll focus on communicating with the computer via a standard serial connection.  We’ll be using a new programming language called “processing” to visualize some information from the Arduino on the computer screen.  If you are new to processing, they have an excellent set of tutorials to help you get started.

The Arduino Contest has been extended! You only have 1 more week to submit your project!

EDIT:
Serial.flush() has changed in Arduino 1.0.  You can use the following instead:
while(Serial.available()>0) Serial.read();

You can download the files associated with this episode here:

GNU GPL License Distributed under the GNU General Public (Open-Source) License.
Please Attribute and Share-Alike.

 

252 comments

  1. Hi Jeremy, I’m having a problem in my application with Matlab Gui -Arduino serial communication. I want to receive data from Arduino when a optical encoder sends me a 1 or a 0 and send it to Matlab Gui, but I don’t know where and how to write my code in order to make my Gui check all the time the state of my digital inputs (4).
    And I have another question, is it possible to send from Arduino to Matlab Gui an array mixed of numbers and text? I don’t know how to write the code for that either in Matlab.
    Please help me, right now I’m using a toggle button_callback to write my code of detecting the state of my inputs in it, but it only detects one time at the begining.

    function EXECUTE_Callback(hObject, eventdata, handles)
    % hObject handle to EJECUTA (see GCBO)
    % eventdata reserved – to be defined in a future version of MATLAB
    % handles structure with handles and user data (see GUIDATA)

    % Hint: get(hObject,’Value’) returns toggle state of EJECUTA

    delete(instrfind({‘Port’},{‘COM3’}))
    global c fec psc fem aam
    %%COMUNICATION ARDUINO UNO
    c=arduino(‘COM3′);

    %INPUTS FOR THE ARRAY

    c.pinMode(2,’input’);
    c.pinMode(3,’input’);

    %Sensors
    þC
    c.pinMode(4,’input’);
    %PSC
    c.pinMode(5,’input’);
    þM
    c.pinMode(6,’input’);
    «ADM
    c.pinMode(7,’input’);

    %p%Led
    c.pinMode(13,’output’);

    %%check state of sensors
    fec=0;
    psc=0;
    fem=0;
    aam=0;

    fec=c.digitalRead(4); %%sensor1
    psc=c.digitalRead(5); %% sensor2
    fem=c.digitalRead(6); %%sensor3
    aam=c.digitalRead(7); % sensor4

    handles.c=c;

    if fec==1
    c.digitalWrite(13,1); % ledpin13 high
    Popup_6;
    else
    c.digitalWrite(13,0); % ledpin13 low
    end

    if psc==1
    c.digitalWrite(13,1);
    Popup_6;
    else
    c.digitalWrite(13,0);
    end
    if fem==1
    c.digitalWrite(13,1);
    Popup_6;
    else
    c.digitalWrite(13,0);
    end
    if aam==1
    c.digitalWrite(13,1);
    Popup_6;
    else
    c.digitalWrite(13,0);
    end

    1. Hi. Please consider Jeremy’s time. It is a hard,difficult and impossible task to look through pages of code from loads of interested parties. So – have a heart

  2. I just got a Arduino uno and I tried this tutorial and It recives the right data but also adds -38 to the end every time.

    1. I too am getting a -38 after all is said and done. Not sure what’s causing it. On another point thanks for these great tutorials! You have one of the best lessons out there from what I’ve seen so far. Thanks for all the help!

  3. On Processing 2 the function readStringUntil(char) has not been included yet in the serial library, therefore you must replace the function readStringUntil(‘\n’) with readString().

    I’m using Com6 and the screen resolution is 1366,768, therefore on my Win8 64b the code is:

    import processing.serial.*;
    Serial port;
    float brightness = 0;

    void setup()
    {
    size(1366,768);
    port = new Serial(this, “COM6”, 9600);
    port.bufferUntil(‘\n’);
    }

    void draw()
    {
    background(0,0,brightness);
    }

    void serialEvent (Serial port)
    {
    brightness = float(port.readString());
    }

  4. I am trying to follow a tutorial from mad science (link posted below) but cannot get the Processing 2 to work as it indicates ‘Cannot find anything named ‘Serial'”, I’ve been all over and researched for days. I am trying to get this project done for my Physics class. Can you help/point me in the right direction?

    This is what I have in Processing 2:

    void setup() {
    // initialize the serial communication:
    Serial.begin(9600);
    }

    void loop() {
    // send the value of analog input 0:
    Serial.println(analogRead(A0));
    // wait a bit for the analog-to-digital converter
    // to stabilize after the last reading:
    delay(2);
    }

    http://mad-science.wonderhowto.com/how-to/diy-polygraph-machine-detect-lies-with-tin-foil-wire-and-arduino-0134599/

    1. Hi here is the answer to Serial.Flush() not working:

      int ledPin = 11;

      void setup()
      {

      Serial.begin(9600);
      pinMode(ledPin,OUTPUT);
      }

      void loop()
      {

      // Make Sure this line is included
      // Have the Ardunio wait to receive input

      while(Serial.available() == 0) {
      delay(500);
      }

      // Read the input

      int val = Serial.read() – ‘0’;

      if (val == 1)
      {
      Serial.println(“Led is ON” );
      digitalWrite(ledPin,HIGH);

      }

      else if ( val == 0 )
      {
      Serial.println(“Led is OFF”);
      digitalWrite(ledPin,LOW);
      }

      else
      {

      Serial.println(“Invalid”);

      }

      // Serial.flush(); ( Failed )

      // Make Sure this line is included

      while(Serial.available() > 0)
      {
      Serial.read();
      }

      }

      1. even this is not working on mine…..it still prints all the Garbage Inputs…..its annoying
        SOLUTION???

  5. Serial.flush(); AND while(Serial.available()>0) Serial.read(); doesn’t flush out serial buffer on my Arduino Mega. Any advice?

    1. p.s. Also during pot readout using Processing I had to replace brightness = float(port.readStringUntil(‘\n’)); with brightness = float(new String(port.readBytesUntil(‘\n’))); in order to avoid the error “The function readStringUntil(char) does not exist.”.

  6. I struggled with the Serial.flush() alternative as well. I finally figured it out by putting a small delay in the initial while() statement. Without the delay it would never clear out the incoming buffer in the second while loop. Here is my sample code:

    void loop()
    {
    while(Serial.available() == 0) { delay(500); }

    int val = Serial.read() – ‘0’;

    if(val == 1)
    {
    Serial.println(“Led is on”);
    digitalWrite(ledPin, HIGH);
    }
    else if(val == 0)
    {
    Serial.println(“Led is off”);
    digitalWrite(ledPin, LOW);
    }
    else
    {
    Serial.println(“Invalid!!”);
    }

    while(Serial.available() > 0) {
    Serial.read();
    }
    }

    1. Hello Kyle, your solution worked, it was spotted, all other examples were either confusing or did not work, you just need to put comments explaining the Serial.available statement, the reason for the Delaying to 500 and the Serial.read().

      When I saw this problem on Jeremy Blum YouTube Channel, I knock my head against the wall and refused to go forward until i found a solution, it took almost an hour before I found the message board, it was worth it.

      Thank ***

    2. Hi Kyle,

      Thanks for your solution. It only fails when you input a reallllly big number, so it’s good enough for most things. I noticed that as you decrease the delay the max number characters before a double invalid also decreases. However I haven’t found a better solution than this one.

    3. I know this solution is years old, but I’d like to ask, is the Serial.read() function asynchronous to the remaining code? Knowing that C is procedural, I can’t fully understand why we need a delay while we wait for the buffer to be cleared. Unless of course, the read() function is running on its own independent thread.

  7. Hey jeremy i bought your book before the break to learn more about the arduino and im happy to say im very pleased with it so far!

  8. hello jeremy, first of all thank you for all of your videos.
    i think you explain them very well, and i enjoy to learn from you.
    good job!!

    i want to ask you some questions and i will be more than happy if you reply to me:

    1. i want the arduino uno board read some data from text file in my computer
    for example: i want the arduino read the date 23.1253 from text file.
    how can i do that?
    which cables i need – usb only or rs232?
    whether need i use ttl converter voltage?

    2. i want to send the data 23.1253 from matlab , to the arduino uno board.
    how can i do that?
    which cables i need?
    whether need i use ttl converter voltage?

    thanks a lot!

  9. Hi Jeremy, I’ve been meddling around with an arduino for a couple of weeks now and I’ve been looking for interesting ways to have it interact with processing. Until now all I had was the same data leaving the arduino entering processing’s console and not really doing much. This tutorial has helped me out so much. Thanks and keep up the good work.

  10. Hi
    when i write the first code when i write numbers it returns me except the number i except , one more number..

    for example when i push 1 it returns me 49 an 13

    What’s wrong?

    Check out my print screen

    http://prntscr.com/30rrfq

    thank’s

    1. reply for this comment

      matt:
      Acording to a ascii table its a 10. Wich is a new line feed but turns to -38 when I -0

  11. Hye Jeremy Blum,
    I have problem with the connection between arduino and Matlab GUI.
    I need take data from Arduino to sent to Matlab GUI.
    How I need to write the program?
    May you show to me the basic of procedure to do that?
    Really appreciate your helps.
    Thank you.

  12. Hey! i am making a project with kinect + processing + arduino.
    I got some data from kinect onto processing. Now i want to send this data to arduino. Can you kindly help me out ?
    I have no idea about it so a small clue will also be helpfull :)

  13. Hey! i am making a project with kinect + processing + arduino.
    I got some data from kinect onto processing. Now i want to send this data to arduino. Can you kindly help me out ?
    I have no idea about it so a small clue will also be helpfull :)
    or atleast share your own code for help . Thanks

  14. Hi Jeremy!

    Great video!, i am doing something similar getting data from a airflow sensor to processing, but i found that there is a lag of 5 seconds in the data between arduino and processing. That is a big problem, do you know how to avoid it?

    Thanks!

  15. Hey Jeremy, i am trying to have a serial connection with arduino Leonardo for sending data via pc to arduino.
    I use linux and i am using LIbSerial, but as i try to run my program i have no reply from arduino.
    I would be glad if you could help me cause i need it for my university final project.

    Thanks a lot
    Marios

    This is my arduino code:

    const int Relay1=12;
    const int Relay2=11;
    int bytesRead;
    char incoming[11];

    void setup(){
    Serial.begin(9600);
    pinMode(Relay1,OUTPUT);
    pinMode(Relay2,OUTPUT);
    digitalWrite(Relay2,LOW);
    digitalWrite(Relay1,LOW);
    }

    void loop(){
    int matchFlag = 0;
    int end1;

    if(Serial.available()>0){
    bytesRead = Serial.readBytesUntil(‘\n’, incoming, 10);
    incoming[bytesRead] = ”; // Add null terminator…
    if (strcmp(incoming, “lights”) == 0){
    Serial.println(“Lights matched”);
    matchFlag = 1;
    digitalWrite(Relay1, HIGH);
    end1=Serial.write(“end”);
    }
    if (strcmp(incoming, “voltage”) == 0){
    Serial.println(“Voltage matched”);
    matchFlag = 1;
    digitalWrite(Relay2, HIGH);
    end1=Serial.write(“end”);
    }

    if (strcmp(incoming, “end”) == 0){
    Serial.println(“End matched”);
    matchFlag = 1;
    digitalWrite(Relay2,LOW);
    delay(3000);
    digitalWrite(Relay1,LOW);
    end1=Serial.write(“end”);
    }
    if (matchFlag == 0){
    Serial.println(“error”);
    end1=Serial.write(“end”);
    }
    }
    }

    And this is my pc code:

    #include
    #include
    #include
    #include
    #include
    #include
    #include

    using namespace std;
    using namespace LibSerial;

    int main(){

    char end[4] = { 0 };
    int reply;
    int f=0;
    SerialStream arduino;
    arduino.Open(“/dev/ttyS0”);
    arduino.SetBaudRate(SerialStreamBuf::BAUD_9600);
    arduino.SetCharSize(SerialStreamBuf::CHAR_SIZE_8);
    arduino.SetNumOfStopBits(1);
    arduino.SetFlowControl(SerialStreamBuf::FLOW_CONTROL_NONE);
    arduino.SetVTime(1);
    arduino.SetVMin(100);
    if(!arduino.good()){
    f=1;
    arduino.Open(“/dev/ttyS1”);
    arduino.SetBaudRate(SerialStreamBuf::BAUD_9600);
    arduino.SetCharSize(SerialStreamBuf::CHAR_SIZE_8);
    arduino.SetNumOfStopBits(1);
    arduino.SetFlowControl(SerialStreamBuf::FLOW_CONTROL_NONE);
    arduino.SetVTime(1);
    arduino.SetVMin(100);
    }
    if(!arduino.good()){
    cout<<"Arduino not connected \n";

    }
    if(f==0){
    cout<<"Arduino connected in /dev/ttyS0 port \n"<<"with: \n"<<"Baudrate:9600 \n";

    }
    if(f==1){
    cout<<"Arduino connected in /dev/ttyS1 port \n"<<"with: \n"<<"Baudrate:9600 \n";

    }

    arduino<<"lights"<<std::endl;
    cout<<"is here? \n";
    while(strcmp(end,"end")!=0){
    arduino.read(end,4);
    cout<<"is here? \n";
    }
    cout<<"is here? \n";
    arduino.Close();
    return 0;

    }

  16. still can’t get a single invalid from a string of char, I have tried the ex of replacing Serial.flush
    but no luck see code

    int ledPin=13;
    void setup()
    {
    //Create Serial object
    Serial.begin(9600);
    pinMode(ledPin,OUTPUT);

    }
    void loop()
    {
    //Have the arduino wait to recive input
    while(Serial.available()==0);
    //Read the Input
    int val=Serial.read()-‘0’;

    if(val==1)
    {
    Serial.println(“led is on”);
    digitalWrite(ledPin,HIGH);
    }
    else if (val==0)
    {
    Serial.println(“led is off”);
    digitalWrite(ledPin,LOW);
    }
    else
    {
    Serial.println(“invalid”);
    }
    // Serial flush not working
    Serial.flush();
    }

    1. The Serial.flush() command no longer dumps the input buffer, it only pauses to allow the output buffer to finish writing. Using Serial.flush() to dump the output completely before trying to read in the rest of the input buffer to consume it seems to work. Although I am unsure if this is the real solution, or if it works because it introduces a small sleep (like the example above by Kyle Rogers which seems to work as well)… Try:

      int ledPin = 13;

      void setup() {
      // create the serial object
      Serial.begin(9600);

      pinMode(ledPin, OUTPUT);
      }

      void loop() {
      // have the arduino wait to receive input
      while (Serial.available() == 0);

      // read the input
      int val = Serial.read() – ‘0’;

      if (val == 1) {
      Serial.println(“Led is on.”);
      Serial.flush(); // <—- flush the output!
      digitalWrite(ledPin, HIGH);
      }
      else if (val == 0) {
      Serial.println("Led is off.");
      Serial.flush(); // <—- flush the output!
      digitalWrite(ledPin, LOW);
      }
      else {
      Serial.println("invalid!");
      Serial.flush(); // 0) {
      int devnull = Serial.read(); // <— now the input buffer should get consumed!
      }

      }

  17. i have written the same code for communicating of arduino with processing by turning the potentiometer knob project.but when i run the processing sketh it says com32 is busy .because i also have opened up my
    arduino’s serial window.
    but also when i turn of the arduino sreial window and run the processing sketch i get nothing.

  18. /*
    >>upon the void loop procedure the program whould ask if the serial.available is either 1 or 2.
    >> then i declare the variable neo as serial.read
    >>and the variable neo will be put on a switch satatement
    >>case neo = 1: the program will perform the specific command on the case

    PROBLEM:
    >> during the each case statement only the first line of code is being perform.
    HOw could it be fix?????

    how could i make it perform an other void procedeure(viod programFirst) from the case.?

    */

    #include

    const int echoPin =2;//Sensor1
    const int initPin =3;//Sensor1
    int distance = 0;
    HBridge motorsEntrance(11,6,8);
    int led = 14;
    char neo;
    void setup()
    {
    pinMode(led, OUTPUT);
    pinMode(initPin, OUTPUT);
    pinMode(echoPin, INPUT);
    Serial.begin(9600);
    motorsEntrance.begin();

    }
    void loop()
    {
    if(Serial.available()== 1 || Serial.available()== 2)
    {
    neo = Serial.read();
    switch(neo)
    {
    case ‘1’:
    {
    motorsEntrance.Forward(255);
    delay(5000);
    motorsEntrance.Stop(); //it execute until here
    void programFirst(); // and this part is not executed
    break;
    }
    default:
    {

    motorsEntrance.Forward(255);
    delay(5000);
    motorsEntrance.Stop();
    digitalWrite(led, HIGH);
    delay(500);
    digitalWrite(led, LOW);
    delay(500);
    Serial.println(“System Error!”);
    break;
    }
    }
    }
    }
    void programFirst()
    {
    {
    digitalWrite(initPin, LOW);
    delayMicroseconds(5); //Start Measurment
    digitalWrite(initPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(initPin, LOW);
    unsigned long pulseTime = pulseIn(echoPin, HIGH);
    int distance = pulseTime/58;

    if (distance >= 150 || distance <= 0 )
    {
    digitalWrite(led, HIGH);
    delay(0);
    Serial.println(distance);
    motorsEntrance.Stop();
    delay(5000);
    }
    else
    {
    motorsEntrance.Backward(255);
    delay(5000);
    motorsEntrance.Stop();
    digitalWrite(led, LOW);
    delay(0);
    }
    }
    }

    by the way i'm using an ultrasonic sensor in here to measure a specific distance.
    i hope u can help to debug this problem or at least advice me some pointers to improve this program. :)

  19. Hi
    I was try to control sound sensor through ardino uno. Try to see the output in serial monitor. I work well 1 time. But after that i cant able to writ any program because ardino us still sendind data. It hang up in that program it self. What can i do to make erase of that program

  20. Hi,

    Is there a simple way of using processing to set a range of values then if the analog input from the arduino is between that specific range of values do something like change background color?

    Thanks.

  21. hey jeremy,
    this is vinay .. i am trying interaface gsm module and bluetooth module to ardunio..
    here is my code plz help me year.
    /*
    * created by Rui Santos, http://randomnerdtutorials.com
    * Control 2 DC motors with Smartphone via bluetooth
    * 2013
    */
    int motor1Pin1 = 3;
    int sensor=4;// pin 2 on L293D IC
    int state;
    int flag=0; //makes sure that the serial only prints once the state
    int stateStop=0;
    void setup() {
    // sets the pins as outputs:
    pinMode(motor1Pin1, OUTPUT);
    pinMode(sensor,INPUT);
    // sets enable1Pin and enable2Pin high so that motor can turn on:
    // initialize serial communication at 9600 bits per second:
    Serial.begin(9600);
    }

    void loop() {
    int qwe=digitalRead(sensor);

    //if some date is sent, reads it and saves in state
    if(Serial.available() > 0){
    state = Serial.read();
    flag=0;
    }

    // if the state is ‘1’ the DC motor will go forward
    else if (state == ‘1’) {
    digitalWrite(motor1Pin1, HIGH);
    if(flag == 0){
    Serial.println(“turn on”);
    flag=1;
    }
    }

    // if the state is ‘2’ the motor will turn left
    else if (state == ‘2’) {

    digitalWrite(motor1Pin1, LOW);
    if(flag == 0){
    Serial.println(“off”);
    flag=1;
    }
    delay(1500);
    state=3;
    stateStop=1;
    }

    // if the state is ‘3’ the motor will Stop

    // if the state is ‘4’ the motor will turn right

    // if the state is ‘5’ the motor will Reverse

    //For debugging purpose
    //Serial.println(state);
    }
    void pro()
    {
    Serial.print(“AT+CMGS=”);
    Serial.print(‘”‘);
    //Serial.print(“+919014639486”);
    Serial.print(“+919885184726”);

    Serial.print(‘”‘);
    Serial.print(‘\r’);
    Serial.print(“THIS IS ARDUINO”);
    Serial.write(26);
    }

  22. hey jeremy,
    this is vinay .. i am trying interaface gsm module and bluetooth module to ardunio..
    here is my code plz help me year.

    int motor1Pin1 = 3;
    int sensor=4;
    int flag=0;
    int stateStop=0;
    int state;
    void setup() {
    // sets the pins as outputs:
    pinMode(motor1Pin1, OUTPUT);
    pinMode(sensor,INPUT);
    Serial.begin(9600);
    }

    void loop() {
    int qwe=digitalRead(sensor);
    if(qwe==HIGH)
    {
    pro();
    }

    if(Serial.available() > 0){
    state = Serial.read();
    flag=0;
    }

    else if (state == ‘1’) {
    digitalWrite(motor1Pin1, HIGH);
    if(flag == 0){
    Serial.println(“turn on”);
    flag=1;
    }
    }

    else if (state == ‘2’) {

    digitalWrite(motor1Pin1, LOW);
    if(flag == 0){
    Serial.println(“off”);
    flag=1;
    }
    delay(1500);
    state=3;
    stateStop=1;
    }

    }
    void pro()
    {
    Serial.print(“AT+CMGS=”);
    Serial.print(‘”‘);
    //Serial.print(“+919014639486”);
    Serial.print(“+919885184726”);

    Serial.print(‘”‘);
    Serial.print(‘\r’);
    Serial.print(“THIS IS ARDUINO”);
    Serial.write(26);
    }

  23. Hi Jeremy!

    Any knowledge about interfacing arduino and vb.net 2012?

    I’m using servo motor attached in digital pin 9 arduino uno, what I want is the servo motor will execute the number of sweeps depends on the value of a variable displayed in a textbox without using button (if its possible). Thank you!

  24. Hi! i have a problem
    Serial.flush() not clearing the garbage
    i am using arduino UNO R3 and arduino IDE is 1.7.8

    int ledPin = 13;

    void setup() {
    // Create serial object
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);

    }

    void loop() {
    // wait to receive input
    while (Serial.available() == 0);

    // Read input
    int val = Serial.read() – ‘0’;

    if (val == 1) {
    digitalWrite(ledPin, HIGH);
    Serial.println(“Led is On”);
    }
    else if (val == 2) {
    digitalWrite(ledPin, LOW);
    Serial.println(“Led is Off”);
    }
    else {
    Serial.println(“Invalid!”);
    }
    Serial.flush();
    }

  25. Hello Jeremy,
    Long time youtube fan here. I’m currently working on a controller program in vb to have the arduino do fun things with an led strip. however, I’ve run across a stumbling block. I’m using vb.net and I am able to establish com and send commands to the arduino, but if I want to loop a routine, (for instance blink), i get stuck in a loop. Can you give some ideas on how to allow the arduino to continue to listen for commands while a loop is doing other things like flashing the strip? I put a snippet of my code below.

    arduinocode
    ____________________
    void loop()
    {
    if (Serial.available() > 0)
    {
    recvWithStartEndMarkers();
    if (newData)
    {
    processdata();
    }

    }

    }

    void processdata();
    {
    if (newData){
    newData = false;
    if (debug) { Serial.println( receivedChars ); }

    if (strcmp(receivedChars, “START”) == 0)
    {
    sendStartMessage();
    }

    if ( receivedChars[4] == ‘1’)
    {
    // for ( byte Count = 1; Count <= 15; Count++)
    // {
    digitalWrite(13,HIGH);
    // }
    if (feedback) { sendOK(1); }
    }
    if ( receivedChars[4] == '2')
    {

    digitalWrite(13,LOW);
    if (feedback) { sendOK(2); }
    }
    /* that part works fine, because it is simply turning on and off the led */

    if (receivedChars[4] == 'a')
    {

    gumballs(); /// call function to flash lights …… how do i do this yet still alllow the arduino to listen to the port for another command while the lights are flashing?
    do i loop code here? or do I loop it in the function? or do I loop the command sent to the arduino in vb?

    }

    any help you could add would be greatly appreciated.
    Thanks

  26. can’t seem to get this to work keep getting an Error compiling. the funny thing is i have not even got to the flush problem yet. so this is my script and any help would be awesome.

    int ledPin = 13;

    void setup()
    {
    // put your setup code here, to run once:
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);
    }

    void loop()
    {
    // put your main code here, to run repeatedly:
    while (Serial.available() == 0);

    int val = Serial.read() – ‘0’;

    if (val == 1)
    {
    Serial.println(“led is on”);
    digitalWrite(ledPin. HIGH);
    }
    else if (val == 0)
    {
    Serial.println(“led is off”);
    digitalWrite(ledPin. LOW);
    }
    else
    {
    Serial.println(“Invalid”);
    }
    while(Serial.available()>0)
    {
    Serial.read();
    }
    }

    1. One of the problems that I see is that in your digitalWrite statements, ledPin and LOW should be separated by a comma. It should look like this:

      digitalWrite(ledPin, LOW);

      See what happens when you make that change.

  27. how send data received by IR rx and send it through serial [USB] and data from serial [IR code ] to IR tx .can you find the solution for this ???????? and if you do ,pls share the code .

  28. HI; I want create an application using visual c++ this one would countain a text box where the user will put a message, then i want send this message to arduino and read it using setal communication

  29. Hi Jeremy… Greetings of the day…
    I need your help, I am working with RF module 433MHz. I want to switch the digital pins of reaciver side arduino through the transmitter arduino, at list 4 pins. I have seen different kind of codes on different sides but I don’t understand the it bcz of absence of discreaption…So pls help me, send me the sample code for 4 LEDs No/Off through RF. I am using Arduino nano both side….
    And thanks in advance….

  30. I am actually detecting the tag read by my RFID reader on Arduino. So i wish to connect the rfid reader software and get the values read on time onto my Arduino. Is there any way to connect my rfid software .exe file with Arduino.

Leave a Reply to vinay Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisement