message:
Compiling Error

I am trying  to compile this code on arduino IDE...It showing error
code is

    #include <IRremote.h>

    int RECV_PIN = 6;
    int led = 12;//1FE50AF
    int led1 = 10;//1FED827
    int led2 = 9; //1FEF807
    int led3 = 8;//1FE3087
    int led4 = 7;//1FEB04F
    boolean previousState=LOW;
    boolean previousState1=LOW;
    boolean previousState2=LOW;
    boolean previousState3=LOW;
    boolean previousState4=LOW;
    boolean state;
    boolean state1;
    boolean state2;
    boolean state3;
    boolean state4;
    IRrecv irrecv(RECV_PIN);
    decode_results results;
    void setup()
    {
      Serial.begin(9600);
      pinMode(12,OUTPUT);
      pinMode(10,OUTPUT);
      pinMode(9,OUTPUT);
      pinMode(8,OUTPUT);
      pinMode(7,OUTPUT);
      irrecv.enableIRIn();// Start the receiver
    }
    void loop() {
      if (irrecv.decode(&results))
      {
        Serial.println(results.value, HEX);
        switch(results.value)
        {
           case 0x1FE50AF:
           if (previousState == LOW)
           {state=HIGH;
            digitalWrite(led,state);
           previousState=state;}
           else
           {state=LOW;
           digitalWrite(led,state);
           previousState=state;}
           break;
            case 0x1FED827:
           if (previousState1 == LOW)
           {state=HIGH;
            digitalWrite(led1,state1);
           previousState1=state1;}
           else
           {state1=LOW;
           digitalWrite(led1,state1);
           previousState1=state1;}
           break;
           case 0x1FEF807:
           if (previousState2 == LOW)
           {state2=HIGH;
           digitalWrite(led2,state2);
           previousState2=state2;}
           else
           {state2=LOW;
           digitalWrite(led2,state2);
           previousState2=state2;}
           break;
            case 0x1FE30CF:
           if (previousState3 == LOW)
           {state3=HIGH;
            digitalWrite(led3,state3);
           previousState3=state3;}
           else
           {state3=LOW;
           digitalWrite(led3,state3);
           previousState3=state3;}
           break;
            case 0x1FEB04F:
           if (previousState4 == LOW)
           {state4=HIGH;
            digitalWrite(led4,state4);
           previousState4=state4;}
           else
           {state4=LOW;
           digitalWrite(led4,state4);
           previousState4=state4;}
           break;
        }
        irrecv.resume(); // Receive the next value
      }
    }

[![enter image description here][1]][1]

**Error massage which I Getting during compiling**

> Arduino: 1.6.5 (Windows XP), Board: "Arduino/Genuino Uno"
>
> Using library IRremote in folder: C:\Documents and Settings\Santanu
> Mandal\My Documents\Arduino\libraries\IRremote (legacy)
>
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard -IC:\Documents
> and Settings\Santanu Mandal\My Documents\Arduino\libraries\IRremote
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IRrecvDemowithled.cpp
> -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IRrecvDemowithled.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard -IC:\Documents
> and Settings\Santanu Mandal\My Documents\Arduino\libraries\IRremote
> -IC:\Documents and Settings\Santanu Mandal\My Documents\Arduino\libraries\IRremote\utility C:\Documents and
> Settings\Santanu Mandal\My
> Documents\Arduino\libraries\IRremote\IRremote.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IRremote\IRremote.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -x
> assembler-with-cpp -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605
> -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_pulse.S -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring_pulse.S.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os
> -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\hooks.c -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\hooks.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os
> -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\WInterrupts.c -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WInterrupts.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os
> -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\wiring.c
> -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os
> -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_analog.c -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring_analog.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os
> -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_digital.c -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring_digital.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os
> -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_pulse.c -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring_pulse.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -c -g -Os
> -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\wiring_shift.c -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring_shift.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\abi.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\abi.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\CDC.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\CDC.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial0.cpp
> -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial0.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial1.cpp
> -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial1.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial2.cpp
> -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial2.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial3.cpp
> -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial3.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\HID.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HID.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\IPAddress.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IPAddress.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\main.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\main.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\new.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\new.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\Print.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Print.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\Stream.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Stream.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\Tone.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Tone.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\USBCore.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\USBCore.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\WMath.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WMath.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os
> -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program
> Files\Arduino\hardware\arduino\avr\variants\standard C:\Program
> Files\Arduino\hardware\arduino\avr\cores\arduino\WString.cpp -o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WString.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring_pulse.S.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\hooks.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WInterrupts.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring_analog.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring_digital.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring_pulse.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\wiring_shift.c.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\abi.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\CDC.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial0.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial1.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial2.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HardwareSerial3.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\HID.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IPAddress.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\main.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\new.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Print.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Stream.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\Tone.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\USBCore.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WMath.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-ar rcs
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\WString.cpp.o
>
>
> C:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc -Os
> -Wl,--gc-sections -mmcu=atmega328p -o C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/IRrecvDemowithled.cpp.elf
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IRrecvDemowithled.cpp.o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp\IRremote\IRremote.cpp.o
> C:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp/core.a
> -LC:\DOCUME~1\SANTAN~1\LOCALS~1\Temp\build8586850450850335044.tmp -lm
>
> collect2.exe: error: ld returned 5 exit status Error compiling.

  [1]: https://i.stack.imgur.com/7tCAH.jpg

body:
You have been bitten by a bug in the compiler toolchain. [The bug has already been reported](https://github.com/arduino/Arduino/issues/2989). Suggested workarounds:

* add a few unused global variables
* add some unused functions.


sender: user

message:
How to display an entire incoming string from the serial monitor in arduino ide?

this is my first question in this forum.

I need to receive a string from the Arduino serial monitor and display it when the communication is over. I have a similar problem like the one discussed in this thread:

https://electronics.stackexchange.com/questions/45543/how-do-i-receive-an-entire-string-as-opposed-to-1-character-at-a-time-on-the-ard

Only I'm using the Arduino serial monitor instead of a RaspberryPi to send strings so I can't program the sender to attach an identifier like '\n' at the end of the string.

    char inData[20];
    char inChar=-1;
    byte index = 0;

    while (Serial.available() > 0){
      ending[1]=ending[1]+1;
      if(index < 19){

          inChar = Serial.read();
          inData[index] = inChar;
          index++;
          inData[index] = '\0';
          Serial.flush();
      }
      Serial.print(inData);Serial.print("\t");Serial.println();
    }

What I receive in the console looks like this:

    M
    Me
    Mes
    Mess
    Messa
    Messag
    Message

I need to display only the final string

    Message

The code has to know when the incoming string ended and then display it once.

I'd really appreciate any help I can get.

sender: assistant

body:
If you really want a string. Try using `Serial.readString()`. It will return the full string.

The code could look like this:

    if(Serial.available()  > 0)
    {
      String message = Serial.readString();
      Serial.println(message);
    }


message:
Arduino Nano (3.0) Use an USB Bluetooth stick

I was thinking to build a very small USB Audio Streaming device with aux output for an amp (I know they already exist, but I like the self invention). So I bought an Arduino Nano and a USB Bluetooth device with was originally for a computer. But I thought I might use it on the Arduino. After I removed the housing and soldered four wires onto the USB plug:

https://www.dropbox.com/s/ye5vveb98sfz1zq/IMG_20161030_132648_01.jpg?dl=0

I needed to know how to wire them:

https://www.moddiy.com/product_images/uploaded_images/patillaje-conector-usb.jpg

So I connected:

- "1" to 5V+ on arduino
- "2" and "3" need to be connected to txd and rxd on the arduino (but I don't know whitch way around)...
I read that I need to have 3.3v on "3" or the "+" wire but I have 5V Output on the digital Pins on the arduino (so I need some resistors, but I'm not familiar with calculating them).
- "4" to gnd

Can someone confirm and / or provide some information for me to get this thing running (Bluetooth device enabled and functioning)?

Further steps would be:

- coding the arduino to Use the Bluetooth module for audio streaming - preferrably three Channel.
- configure the arduino to give the stream to an amp.

I know my knowledge of electronics is not very good and I need some education. If you can provide some good learning websites - feel free to suggest.

body:
Interfacing an Arduino with USB is already VERY hard. USB does not use the same Serial as protocol so don't connect it to Tx and Rx. The only way to interface an Arduino and an USB device is trough a USB shield, which is quite complex already.

Just for you information. USB uses 5V so no voltage divider is needed to reduce it to 3.3V. A voltage divider is pretty much 2 resistors in series where the original voltage goes in one end, the output voltages is between the 2 resistors and the other end is connected to ground. Read more about them [here][1].

Now, communicating with Bluetooth is also complicated, but mix USB + Bluetooth and you get something **ALMOST** impossible (I hope the ALMOST is clear enough for any hatters). It is possible, but seeing you level of knowlage, simply don't risk having a severe depression trying to fingure it out!

In the end of the day, your plan of using that Bluetooth USB module is just going to be crazy complicated and big.

A more effective solution would be to use a module such as the HC-05 Bluetooth module. It is quite cheap if you get it from sites such as Amazon. Link [here][2] for this product on Amazon.com. It is designed with the Arduino in mind thus making programming easier. You project could also be a little smaller, because this module pretty much has the size of your Arduino Nano.

Hope it was helpful!

  [1]: https://learn.sparkfun.com/tutorials/voltage-dividers
  [2]: https://www.amazon.com/Wireless-Bluetooth-Serial-Transceiver-Module/dp/B00INWZRNC/ref=sr_1_2?ie=UTF8&qid=1478464065&sr=8-2&keywords=hc05


message:
void loop followed by other "void" expressions

I hope this is a simple request from a newcomer to Arduino and programming. I have understood that once a program enters a void loop section, it loops round indefinitely. However I have recently seen examples of sketches where another void $$$$$ section follows the closure (by}) of the void loop. As I write this, I am looking at one example concerning a 7 segment display where "void Num_Write(int)" follows the closure of the void loop. If the "loop" section does just that, as I have been lead to believe, how is a following section accessed?

Thank you,
Rob

body:
The `void loop()` section is a function, the same as `void setup()` is a function.  When you start you Arduino program another function, that you can't see in the IDE, call `setup()` and then calls `loop()` repeatedly.

These other function you have seen, i.e. `void Num_Write(int n)` can be called from either `setup()` or `loop()` and they will execute their instructions before returning to the function that called them. Its also possible the `Num_Write()` may call other functions before it returns controller to the function that called it.

The type `void` is used to represent nothing (its actually more complex than that, but for this level of explanation nothing will do).  Other functions may return other types `int`, `char`, `bool` for instance.  So if we had a function like this:

    int theMeaningOfLife(void)
    {
      return 42;
    }

This is a function that returns an `int` (a number) so you would call it like this:

    void setup()
    {
      int number = theMeaningOfLife();
    }

There is one catch, the function has to be declared BEFORE it is used, this allows the compiler to know what you are referring to.  The simplest way of doing this is to write the function above the function that is calling it.  The second way is to just write the function's signature above the function using it, i.e.:

    int theMeaningOfLife(void);

    void setup()
    {
      int number = theMeaningOfLife();
    }

The best way (but not always practical on an Arduino) is to have all the function declarations in a header file (.h) and the code in a .cpp file.  (Have a look a library to see what I mean).

**Summary**

There is only one function that is called repeatedly and that is the `loop` function.
Just because a function returns void doesn't mean its going to loop repeatedly.


message:
relay working problem

I am using circuits.io with Arduino. my program is to blink the led with 2 seconds delay. The led in the circuit blink according to program but the bulb does not blink. I am very weak in electronics. This is what i starting to learn from the scratch. the problem here is the bulb doesnt blink according to the program. which is meant to blink. i have uploaded the circuit image below.. . thanks in advanced.

[![Please check the Image here][1]][1]

  [1]: https://i.stack.imgur.com/YsQWH.png

body:
If you wire up your circuit as shown below, the bulb and the LED should flash together.

[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/EqWJf.png


message:
LED won't turn on and serial monitor won't display values

I am trying to use my Arduino to record some values from a photo-resister. The idea is when a character other than g is read the LED will turn on and 512 values will be recorded.

When I type in a character in the serial monitor whether it is g or not it just says 1 or 0 but doesn't not provide me with the values I need from the photo-resistor. My code is as follows:

    int timeOut = 60000;
    int pollTime = 0;
    int time = 0;
    unsigned long startTime = 0;
    unsigned long endTime = 0;
    int x = 0;
    int Vs[512];
    int analogPin = 0;

    void setup() {
      Serial.begin(9600);
      pinMode(9, OUTPUT);
      while (!waitFor('g', 200, 60e6)) {}
      analogWrite(9, 128);
      startTime = micros();
      for (x = 0; x < 512; x = x + 1)  {
        Vs[x] = (analogRead(analogPin));
      }
      endTime = micros();
      for (int x = 0; x < 512; x = x + 1)  {
        Serial.println(Vs[x]);
      }
      Serial.println(endTime - startTime);
    }

    void loop() {
    }

    boolean waitFor(char in, int pollTime, int timeOut)  {
      boolean done = false;
      char charWait;
      time = micros();
      while (time < timeOut)  {
        if (Serial.available())  {
          charWait = Serial.read();
          done = (charWait == in);
          Serial.println(done);
        }
      }
    }

body:
Like Edgar says, what you need to do is this:

    bool waitFor(char in, int pollTime, unsigned long timeOut)
    {
      while (micros() < timeOut)
      {
        if (Serial.available())
        {
          if (Serial.read() == in)
          {
            Serial.println("done");
            return true;
          }
        }
        delay(pollTime);
      }
      return false;
    }

If it still doesn't run after that then change setup() to this:

    void setup()
    {
      Serial.begin(9600);
      Serial.println("Initialising...");
      pinMode(9, OUTPUT);
      while (!waitFor('g', 200, 60e6)) {}
      Serial.println("g command received...");
      analogWrite(9, 128);
      Serial.println("About to start...");
      startTime = micros();
      for (x = 0; x < 512; x = x + 1)  {
        Vs[x] = (analogRead(analogPin));
      }
      endTime = micros();
      Serial.println("Finished...");
      for (int x = 0; x < 512; x = x + 1)  {
        Serial.println(Vs[x]);
      }
      Serial.print("The result is : ");
      Serial.println(endTime - startTime);
      Serial.println("All finished.");
    }


message:
What is the datatype of the pinMode function?

I just tried it, but the Arduino IDE crashed, I hope its not related.
I want to declare a datatype like this:

    int a = pinMode(pin, OUTPUT);

or something like that, but I'm not sure what datatype the `pinMode` function uses. I looked on the [pinMode documentation page][1], of the Arduino website, and I see basic usage, but not a more clear definition of the source code for that function.

  [1]: https://www.arduino.cc/en/Reference/pinMode

body:
`pinMode(pin, Mode);` is a `void`. It doesn't return anything. It simply sets a pin as an `OUTPUT` or an `INPUT`.

It says it in the link you posted.

>Returns
>
>None

That means that the function doesn't return any value.


message:
Blank.txt at the End of Transmission

I'm using my HC-05 (Master) to receive strings from a sensor (Slave), each string is suppose to have 7 items divided by ',' like so "a,b,c,d,e,f,g". I also have to write these strings in a .txt file in the SD card, being that I receive the strings and save them in a string array to later be written to a file. For some reason I can't receive it and write it to a file simultaneously, it alters the string. So the best way would be an array but when i open the file it's blank and when I print it on screen it starts correctly then prints only the first char of what would be the string. I tried it with 80 strings and it works correctly, so I can only guess it would be insufficient memory, But wouldn't it still write to the file since there is something in the strings.

PS:I'm using Arduino Mega

    #include <SD.h>

    const int tam=480;
    char aux;
    File myFile;

    void setup() {
      Serial1.begin(115200);
      Serial.begin(115200);
      Capture();
    }

    void openSD()
    {
      SD.begin(4);
      if( SD.exists("test.txt") )
      {
        Serial.println("O arquivo de amostras sera removido");
        SD.remove("test.txt");
          if( !SD.exists("test.txt") )
            Serial.println("Arquivo removido com sucesso!");
      }
      myFile = SD.open("test.txt", FILE_WRITE);
    }

    void Capture()
    {
      String test[tam];
      openSD();
      Serial.println("BEGIN");
      for(int i=0;i<tam;i++)
      {
        test[i]="";
        do
        {
          while(!Serial1.available());
          aux=Serial1.read();
          test[i]+=aux;
          Serial.print(aux);
        }while(aux!='\n');
      }
      Serial.println("END");
      for(int i=0;i<tam;i++)
        myFile.print(test[i]);
      myFile.close();
    }

    void loop() {

    }

body:
Rules of sequential file is : **It's saved when its closed,** which mean if the file not closed properly, anything written before will not saved, and you'll get blank file.

so, if you get a blank file while you are sure that the data is received, the only possibility is your program doesn't reach

    myFile.close();

one of the possibility is the received data not fit into your memory, so the '\n' is undetected.


message:
Get Battery voltage on raw

I power my Arduino Mini with 3 AA batteries on `RAW` input. Is it possible to get the voltage on `RAW` and therefore the expected longevity of the batteries?

body:
No. Not directly. You can use voltage divider and measure the result with using internal reference. But it's another current consumption and you can't reduce it by (for example) entering one of the sleep modes.

And if you have `5V` Arduino Mini variant, you can power it directly through `5V` power pin. Otherwise you are losing about `1.5V` on voltage regulator. On `3.3V` variant it might be better, but it also depends on used regulator voltage drop and would be better to power it directly (if you don't have connected anything strictly with `3.3V` power, and for `AVR` based Arduinos it's not a problem)

Anyway, if you power it directly, you can measure the power source voltage by measuring internal bandgap voltage reference against power as reference. But, as far as I know, it can't be done by `analogRead`, as it doesn't support other sources than analog pins.


message:
code for line following robot not working perfectly

I have made a line following robot using 2 IR sensor. My line following robot was working successfully with this code.

    #define LS 2      // left sensor
    #define RS 3      // right sensor

    /*-------definning Outputs------*/
    int LM1= 5;       // left motor
    int LM2= 6;     // left motor
    int RM1= 9;       // right motor
    int RM2= 10;

    void setup()
    {
      pinMode(LS, INPUT);
      pinMode(RS, INPUT);
      pinMode(LM1, OUTPUT);
      pinMode(LM2, OUTPUT);
      pinMode(RM1, OUTPUT);
      pinMode(RM2, OUTPUT);
    }

    void loop()
    {
      if(digitalRead(LS) && digitalRead(RS))     // Move Forward
      {
        digitalWrite(LM1, HIGH);
        digitalWrite(LM2, LOW);
        digitalWrite(RM1, HIGH);
        digitalWrite(RM2, LOW);
      }
     else if(!(digitalRead(LS)) && digitalRead(RS))     // Turn right
      {
        digitalWrite(LM1,HIGH);
        digitalWrite(LM2, LOW);
        analogWrite(RM1,70);
        digitalWrite(RM2,LOW);
      }
      else if(digitalRead(LS) && !(digitalRead(RS)))     // turn left
      {
        analogWrite(LM1,70);
        digitalWrite(LM2, LOW);
        digitalWrite(RM1,HIGH);
        digitalWrite(RM2,LOW);
      }else{
        digitalWrite(LM1, LOW);
        digitalWrite(LM2, LOW);
        digitalWrite(RM1,LOW);
        digitalWrite(RM2, LOW);
      }
    }

As I used only two sensor,sometimes it goes out of the line. So I have tried to make an advanced line following robot which could get back to track automatically when it goes out of the line.But the code is taking only the 1st value of tmp.(tmp=1) even when left sensor touches the line after white sensor and the robot goes out of the line.The value of tmp should be 2 when the robot goes out of the line and the left sensor touches the line after the white sensor.  Here is the code:

    /*-------definning Inputs------*/
    #define LS 2      // left sensor
    #define RS 3      // right sensor

    /*-------definning Outputs------*/
    int LM1= 5;       // left motor
    int LM2= 6;      // left motor
    int RM1= 9;       // right motor
    int RM2= 10;  //right motor
    int tmp;

    void setup()
    {
      pinMode(LS, INPUT);
      pinMode(RS, INPUT);
      pinMode(LM1, OUTPUT);
      pinMode(LM2, OUTPUT);
      pinMode(RM1, OUTPUT);
      pinMode(RM2, OUTPUT);
    }

    void loop()
    {
      if(digitalRead(LS) && digitalRead(RS))     // Move Forward
      {
        digitalWrite(LM1, HIGH);
        digitalWrite(LM2, LOW);
        digitalWrite(RM1, HIGH);
        digitalWrite(RM2, LOW);
      }
     else if(!(digitalRead(LS)) && digitalRead(RS))     // Turn right
      {
        digitalWrite(LM1,HIGH);
        digitalWrite(LM2, LOW);
        analogWrite(RM1,70);
        digitalWrite(RM2,LOW);
        tmp=1;
      }
      else if(digitalRead(LS) && !(digitalRead(RS)))     // turn left
      {
        analogWrite(LM1,70);
        digitalWrite(LM2, LOW);
        digitalWrite(RM1,HIGH);
        digitalWrite(RM2,LOW);
        tmp=2;
      }
      else//out of the line
      {
        if(tmp=1){
          analogWrite(LM1,70);
          digitalWrite(LM2, LOW);
          digitalWrite(RM1,LOW);
          analogWrite(RM2,70);
        }else if(tmp=2){
          digitalWrite(LM1,LOW);
          analogWrite(LM2, 70);
          analogWrite(RM1,70);
          digitalWrite(RM2,LOW);
        }
      }
    }

body:
This test:

    if (tmp = 1)

is always true. You are assigning `1` to `tmp` and that value (1), when
interpreted in a boolean context (i.e. as a truth value), is `true`.

You probably mean

    if (tmp == 1)

and similarly for the next test.


message:
ATtiny84A support with "Attiny" board manager installed to Arduino IDE

Referring to page http://highlowtech.org/?p=1695, is it possible to program ATtiny84A as well, or just the chip version ATtiny84 (without "A")? Does anybody know?

body:
According to the PDF [ATTiny24/44/84 to ATTiny24A/44A/84A Migration AppNote][1] it should be pretty easy as there are only some differences in electrical specifications. No changes in registers or so.

The signature bytes are the same too, so it should be posible even without adding another boards.

  [1]: http://www.atmel.com/Images/doc8187.pdf


message:
Using Arduino as Keylogger

Is it possible to use arduino uno r3 as USB keylogger by connecting the usb male pin to CPU and keybord cable to female USB pin of arduino.
So that the keystrokes are stored in EEPROM. Without using an external storage modules or other components?

I am new to arduino, even suggestions are appreciated.

Thanks in advance.[![Somthing like this][1]][1]

  [1]: https://i.stack.imgur.com/2mo11.png

body:
It is highly unlikely using an arduino uno r3.

USB Device: (To emulate a HID (Human Interface Device) Keyboard):

While [there are Arduino libraries for emulating a keyboard][1], these will not work with the Uno R3.  Instead, to make a Uno R3 act like a USB Keyboard Device, you need to reprogram the 2nd processor on the board and switch it from a USB Serial Device to a USB Keyboard Device.  This is talked about in [this stackexchange question][2].

USB Host (to talk to a USB Keyboard):

I do not believe there are any software solutions for emulating a USB Host on most Arduinos. Certainly not a Uno R3.  A USB Host is a very complex software & hardware device. Instead, most Arduino projects use a [USB Host Shield][3] for this purpose.

  [1]: https://www.arduino.cc/en/Reference/MouseKeyboard
  [2]: https://arduino.stackexchange.com/questions/1825/keyboard-mouse-libraries-with-uno
  [3]: https://www.arduino.cc/en/Main/ArduinoUSBHostShield


body:
USB-host is hard if not impossible to implement on an UNO.

Though I believe most USB keyboards support PS2 as well (normally done with a USB-to-PS2 plug). So you should be able to talk to the keyboard using the PS2 protocol, which is a lot easier. There are libraries to do this for you.

Next you could use V-USB to emulate a keyboard to the PC. For that USB connection you need to add some resistors and zener diodes, to stay withing the usb specification. This is all explained on the [V-USB website](https://www.obdev.at/products/vusb/index.html).

Using a different Arduino that has real USB support might be a better option. Also the UNO is rather large, so not that easy to hide.


message:
digispark - 2 pin push button to iterate through an hashmap

I'm trying to create a project with my digispark where i can iterate through an hashmap, when i press the push button the digispark writes via digikeyboard the values from an hashmap. Each time i press the button it's supposed to write the first value, then i press the push button again and in the same line it cleans what was written in the first value and writes the second value and so on. when the last value is reached it goes again to the first value if the button is pressed.
Right now i'm trying to put the iterator to work preperlly, this is the code i have:

    #include "DigiKeyboard.h"
    #include "HashMap.h"

    HashMap<String, String> hashMap;
    int i = 0;

    void setup() {
       //setup hashmap
      hashMap.put("key0","test0");
      hashMap.put("key1","test1");
      hashMap.put("key2","test2");
      hashMap.put("key3","test3");
      hashMap.put("key4","test4");

      DigiKeyboard.sendKeyStroke(0);
      pinMode(0, INPUT);
    }
    void loop() {
      int sensorValue = digitalRead(0);
          while(sensorValue ==1 and i < hashMap.count())
          {
            delay(100);
            DigiKeyboard.println( hashMap.valueAt(i));
            i++;
          }
    }

when i plug the digispark it prints automatically the first and the second value ("test0" "test1") and every time i press the button i get nothing.

This is my configuration:
[http://cdn.instructables.com/FZA/0UN8/HI3TXV8D/FZA0UN8HI3TXV8D.LARGE.jpg][1]

Can anyone help me please?

  [1]: http://cdn.instructables.com/FZA/0UN8/HI3TXV8D/FZA0UN8HI3TXV8D.LARGE.jpg

body:
1. Even with a "clean" button, your while() loop will whip through all 5 hashmap values before you can release the button.

 2. Switches and button aren't clean. They will (appear to) bounce, sending many pulses before they settle down to a fully on or fully off state. Read [Nick Gammon's tutorial on de-bouncing][1] switches.

 3. I'm not familiar with your display but if it is a one-line display, and you .println() at it, will the newline character "scroll" the line of text off the display? This could explain why you didn't at least see the final line. You may need a plain .print() call in order not to do that.

 4. Most LCD displays have a set of control codes to clear it, move the cursor, etc., which you would have to embed into the text string you send, or send using separate .print() calls. I don't see any provision in your code for including or sending those, so you'll need to fix that, too.
 Right now, I expect your display receives something like

`test0\ntest1\ntest2\ntest3\ntest4\n`

It probably needs to see something more like

`\033Etest0`

, e.g., for the first one, etc. That cruft at the beginning of the string is the VT52-code,
escE, for "Clear the display". (I have no idea what command set your display uses, but the VT-52 commands have been in use for ... um, hmmph! well, a long time, anyway. :)  You'll probably to replace it with whatever your particular device uses.

  [1]: http://www.gammon.com.au/switches


body:
thank you all.
i've manage to found a solution to my problem with this code, probably is not the most elegant way to do it but it works:

    #include "DigiKeyboard.h"
    #include "HashMap.h"

    HashMap<char*, char*> hashMap;
    int i = 0;
    bool flag;

    const byte switchPin = 0;
    byte oldSwitchState = HIGH;  // assume switch open because of pull-up resistor
    const unsigned long debounceTime = 100;  // milliseconds
    unsigned long switchPressTime;  // when the switch last changed state

    void setup ()
      {
      pinMode (switchPin, INPUT_PULLUP);

         //setup hashmap
      hashMap.put("key0","test0");
      hashMap.put("key1","test1");
      hashMap.put("key2","test2");
      hashMap.put("key3","test3");
      hashMap.put("key4","test4");

      DigiKeyboard.sendKeyStroke(0);

      }  // end of setup

    void loop ()
      {
      // see if switch is open or closed
      byte switchState = digitalRead (switchPin);

      // has it changed since last time?
      if (switchState != oldSwitchState)
        {
        // debounce
        if (millis () - switchPressTime >= debounceTime)
           {
           switchPressTime = millis ();  // when we closed the switch
           oldSwitchState =  switchState;  // remember for next time
           if (switchState == HIGH)
              {
                delay(500);
                flag = true;
               while(i < hashMap.count() and flag == true)
                {
                  DigiKeyboard.println( hashMap.valueAt(i));
                  i++;
                  flag = false;
                  }
              }  // end if switchState is LOW
           }  // end if debounce time up

        }  // end of state change

      // other code here ...

      }  // end of loop


message:
HCSR04 Sensor without delay

I've made a code to make a stepper work together with a HCSR04 sensor. The problem here is that the sensor has to use a delay in order to work. This delay messes with the smootness of the stepper.

If I remove the code for the sensor the stepper runs verry smooth, adding the sensor code causes the stepper to run 'shaky'.

**The code:**

    int trigPin = 11;
    int echoPin = 10;

    void setup()
    {
    pinMode(trigPin, OUTPUT); //Sensor
    pinMode(echoPin, INPUT); //Sensor
    pinMode(6,OUTPUT); // Enable
    pinMode(13,OUTPUT); // Step
    pinMode(12,OUTPUT); // Dir
    digitalWrite(6,LOW); // Set Enable low
    digitalWrite(5,LOW); // Set Step low
    Serial.begin(9600);
    }

    void loop()
    {
    //rotateleft();
    //Serial.println("ik draai nu exact een rotatie linksom");
    //delay(1000);
    //rotateright();
    //Serial.println("ik draai nu exact een rotatie rechtsom");
    //delay(1000);
    //velocity();

     //sensor
     long duration, distance;
     digitalWrite(trigPin, LOW);
     delayMicroseconds(2); //**problem**
     digitalWrite(trigPin, HIGH);
     delayMicroseconds(5); //**problem**
     digitalWrite(trigPin, LOW);
     duration = pulseIn(echoPin, HIGH);
     distance = (duration/2) / 29.1;
     Serial.print ("cm:");
     Serial.print (distance);

    //eigen creatie
    if (distance > 20 && distance < 30)
    {
      digitalWrite(13,HIGH); // Output high
      delayMicroseconds(1000); // Wait
      digitalWrite(13,LOW); // Output low
      delayMicroseconds(1000); // Wait
    }

    if (distance > 10 && distance < 20)
    {
      digitalWrite(13,HIGH); // Output high
      delayMicroseconds(3000); // Wait
      digitalWrite(13,LOW); // Output low
      delayMicroseconds(3000); // Wait
    }

    if (distance > 1 && distance < 10)
    {
      //digitalWrite(13,HIGH); // Output high
      //delayMicroseconds(1000); // Wait
      digitalWrite(13,LOW); // Output low
    }

    else
    {
     velocity();
    }

    }

    void velocity()
    {
     digitalWrite(13,HIGH); // Output high
     delayMicroseconds(500); // Wait
     digitalWrite(13,LOW); // Output low
     delayMicroseconds(500); // Wait
    }
     }

body:
Have you searched for other libraries or example code for this particular sensor?

I found this [NewPing][1] library that claims to have been developed to fix poor performance of such modules due to poor timing methods.

  [1]: http://playground.arduino.cc/Code/NewPing


body:
You only have a single thread of execution of an Arduino.  So you have limited options:

 1. Live with it.
 2. Use two Arduinos.
 3. Use a microcontroller with 2 cores.
 4. Interrupts

2 Is possible, you could have a slave mcu to drive the motor and control it over I2C.  You will still have contention when you are driving the I2C bus, but you can time that so it is not when you are scanning.

3 Is a very similar solution to 2, but is all in one chip.

4. You MIGHT be able to use interrupts which will let processing continue whilst you are waiting for something to occur.  I can't remember if the Arduino has timer interrupts, if it doesn't an external source could generate the interrupts and changes the state of the lines.,


message:
Does the SIM800L works in the US?

I want to know if the SIM800L works on US soil? I can´t get it to work on the H2O network! Does it work wit ATT or I only need the APN settings? If so what are the commands for data connection and configuration? Does the SIM800C works then?

body:
Both SIM800C and SIM800L (you mention both modules in your question) are compatible with the US GSM networks. It is not possible for me to tell if H2O or AT&T have GSM coverage whereever you are trying to use the module. AT&T is planning to shut down their GSM network by the end of 2016. If you issue the `AT+COPS=?` command, the module will list all available networks at your location.

Documentation on the commands required to handle voice calls, SMS or internet connections can be found in the ['SIM800 Series AT Command
Manual'][1].

  [1]: https://cdn-shop.adafruit.com/datasheets/sim800_series_at_command_manual_v1.01.pdf


body:
I wanted to post an update in April 2021 on the status of this question.

The SIM800L will work in the US, but T-Mobile is the only carrier that it can interface with. [AT&T shut down its compatible towers in 2017. T-mobile will shut down its 2G network at the end of 2022](https://www.androidpolice.com/2021/02/05/t-mobile-3g-shutdown-reportedly-delayed-until-2022/).

So, the SIM800L is only good for another year and a half. Maybe you're better off finding a different module!


body: As far as I know 2G and 3G is still around however ATT and Verizon are not taking on anymore subscribers for 2G and 3G. However you might still could use a 3rd party such as ting.


message:
ArduinoISP external programmer produces verification error?

I am using an ArduinoISP external programmer to upload a sketch to an Arduino MEGA.

I set the processor type to MEGA 2560, and use Ctrl-Shft-U to upload using a programmer. My programmer is set to ArduinoISP under tools>Programmer.

So far, I haven't been able to get the sketch to upload without a verification error. Worse, the programmer made it far enough in the upload process to overwrite the bootloader. Trying to re-upload the boot loader ("Burn Bootloader") also fails. The verbose error output is below with the exact error at the bottom.

A previous post suggested that code with a lot of `0xFF` statements in it would fail. I have none.

Following a suggestion in the comments, I unsoldered the power over ISP programmer jumper (SJVCC) on my ArduinoISP. I powered the Arduino using the power jack; however, I got the same verification error.

I have also tried updating the software the the latest version (1.6.12), but that also does not seem to work. I may try to downgrade the software, but this all seems a little futile. Other forums don't seem to have a good answer for similar verification problems.

Is this a known problem? What can I do to fix it? What is particularly frustrating is that the problem occurs intermittently, ocassional after a computer reboot, it will upload successfully one time.

    avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : arduinoisp
    avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x2341-0x0049
         AVR Part                      : ATmega2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     :
    avrdude: programmer operation not supported

    avrdude: Using SCK period of 10 usec
    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.01s

    avrdude: Device signature = 0x1e9801
    avrdude: NOTE: "flash" memory has been specified, an erase cycle will be     performed
         To disable this feature, specify the -D option.
    avrdude: erasing chip
    avrdude: Using SCK period of 10 usec
    avrdude: reading input file     "C:\Users\Michael\AppData\Local\Temp\builddfc205ae09caa85de62f61bf2adae2c7.tmp/Tension_wo_Averaging.ino.hex"
    avrdude: writing flash (9334 bytes):

    Writing | ################################################## | 100% 10.71s

    avrdude: 9334 bytes of flash written
    avrdude: verifying flash memory against     C:\Users\Michael\AppData\Local\Temp\builddfc205ae09caa85de62f61bf2adae2c7.tmp/Te    nsion_wo_Averaging.ino.hex:
    avrdude: load data flash data from input file     C:\Users\Michael\AppData\Local\Temp\builddfc205ae09caa85de62f61bf2adae2c7.tmp/Tension_wo_Averaging.ino.hex:
    avrdude: input file                     C:\Users\Michael\AppData\Local\Temp\builddfc205ae09caa85de62f61bf2adae2c7.tmp/Tension_wo_Averaging.ino.hex contains 9334 bytes
    avrdude: reading on-chip flash data:

    Reading | ################################################## | 100% 7.34s

    avrdude: verifying ...
    avrdude: verification error, first mismatch at byte 0x0600
             0xdd != 0x4a
    avrdude: verification error; content mismatch

    avrdude done.  Thank you.

body:
Sounds like you have a bad Arduino ISP board.

I've had limited success restoring bootloaders on some Arduinos with my bad USBtinyISP programmer by connecting a 9V power supply to the Arduino in addition to the 5V that the ICSP cable provides.  Worth a try.

Note that back when my USBtinyISP was working properly I didn't need to attach 9V, the 5V from the ICSP cable was all the power needed.


message:
How do I measure watts without a CT clamp?

I'm trying to build an "IoT" project for home that will in effect create a smartplug. I'd like to add the capability to measure the watt usage of the plug (and whatever's connected to it). I'd like to not use a CT clamp for this purpose, and I was hoping someone here can help.

I have a 220 V mains connection and I'd like to measure the watts used by a connected appliance to the smart plug is a small as possible form. CT sensors are too big for this purpose.

Thanks.

body:
You can't use a CT sensor to measure power.  CT sensors measure current.  Measuring Watts is the correct unit if you want to know the rate of energy consumption (power) from an outlet.

*Response to a Comment: There are consumer devices that cost only $12.95 that might be ideal, if the only usage scenario is to compare various devices for steady state power draw and you are fine with 3% (1.5 digit) accuracy.  For the 220 VAC (whether split phase or single phase) you would need to gang two of them together appropriately.  These plug-outlet designs are nicely miniature, but will not support checking past values, providing feedback to a control system, or Wattage plotting against date, time of day, or tay of week.*

Measuring of Wattage accurately (to two or three significant digits) is not trivial if the 220 Volt source is an AC power grid, thus the length of this answer.

The basic EE formula for power is P=IV for DC, meaning power is the product of current and voltage.  But you can't just go with **Watts = 220 X current** and expect any more than one significant digit of accuracy.  Grid Voltage may not be a clean sine wave and may vary five or ten Volts under normal conditions.

If you want more than one digit of accuracy, you'll need to calculate RMS (root mean square) power in Watts by sampling both Voltage and current and using the AC principles that extend the simple P=IV relation.   I don't know if you have knowledge of what electrical engineers call RMS.  In case you don't, the articles in the result set of **[This Search](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=calculating+rms+watts+from+samples+of+voltage+and+current)** [1] may be helpful.

Let's hypothetically say you are considering doing the **work necessary to get the two or three significant digits of accuracy in determining power** consumption.  To get a sense of what that would entail, here's some information on doing that properly.  You will want to consider line voltage fluctuation, reduce your noise levels, protect your Arduino board from over-voltage, and follow electrical code reasonably well.

The below measurement fixture design is not small, but it could be miniaturized.  Unfortunately the design of a miniaturized version is large project FAR outside of the scope of an answer in this forum.  You may be one of those that likes the challenge, so I'll share a design for a larger version and leave it to you or other answering parties to think of a miniaturization that meets all these other reasonable goals.

Off the shelf parts to fabricate a full sized power measurement fixture to interface with an embedded board like the Arduino Due, for example:

 1. Two electrical boxes
 2. A length of electrical conduit at least 50 cm long
 3. Electrical hardware to connect the two boxes and secure the AC cord leading to the plog and to the devices being powered.
 4. Two lengths of 2-conductor 18 AWG shielded twisted pair cable with at least 500V rating
 5. Code compliant AC cabling
 6. Wire nuts
 7. Box for the buffering circuit
 8. A good quality digital Voltmeter with RMS AC as one of the options

Fabricate this way, but using proper code-compliant electrical practices in addition to these basic instructions for the main circuits:

 1. Connect the plug to one of the boxes with properly rated AC cord.
 2. Connect the two boxes with the conduit and properly rated power and return wires (white and black).
 3. Connect the second box to the device
 4. In each box, connect the 2 conductors of the shielded twisted pair in parallel to the AC circuit passing through the box with the wire nuts.  You must leave the shields of the two twisted pair lengths isolated (not connected to the box or the ground wire in the AC circuit.
 5. Bring both twisted shielded pairs into the buffering circuit box.

The buffering circuit would condition each of the two AC voltage in three stages.

 1. Surge protector
 2. Resistor divider (see other Arduino articles for this)
 3. Zener diode to further protect the A-to-D converter on the board

The Zener diode and the resistor divider would drop the voltage from 400 V down to below the max voltage of the Arduino board, which any of the voltages might be relative to the ground potential on the Arduino board under certain conditions.  The Arduino Due might be a good choice, because of multiple built in true A-to-D channels and the higher accuracy (digits resolution) than most other Arduino options.

The output of the box for each of the FOUR voltages would be connected to FOUR analog inputs.

 - Vph = the hot (black) coming from the plug
 - Vpr = the return (white) coming from the plug
 - Vlh = the hot (black) going to the load (devices to be powered)
 - Vlr = the return (white) going to the load

In the software you would probably want to measure the above four voltages in immediate succession (no delay between the four analogRead calls) every millisecond for a second, which will capture 60 cycles of data in 1,000 samples, enough to get three significant digits of accuracy in your power measurement.  The 60 samples of 4 channels can be thought of as 1,000 vectors of 5-dimensional data.  The fifth dimension is the time offset in milliseconds.

The software goal would be to calibrate the conversion of the 4 by 1,000 element array of analogRead integers to a 2 by 1,000 element array of doubles that represent instantaneous Voltage and current. Then power in Watts can be calculated from the Voltage-current data set.

When dealing with the 1,000 sample vectors, your loops will start with "for (int index = 0; index < 1000; ++ index) { ...".

You will need to convert your digital values representing the Voltages coming from your resistor divider to physical units.  These are the operations you would do on each sample.

 1. V = Cv * (Vph - Vpr)
 2. I = (Cih * (Vph - Vlh) - Cir * (Vlr - Vpr)) / R

V and I are the doubles that represent instantaneous Voltage and current respectively.

Cv, Cih, Cir, and R are also doubles. They are the calibration constants to convert the analogRead values to line voltages and currents.  A typical way to calibrate their values is to measure the RMS voltages across the three node pairs represented by each subtracted voltage pair in the inner parentheses above and the current, using some constant load.  A good load option would be some non-digital device that is fully warmed up and in some steady state.

From the voltages and currents and the digital values acquired from the four analog channels in the Arduino, with some algebra skill, one can determine the scaling factor C for each of the three cases, by dividing: (V1 - V2) / V, where V1 and V2 are the RMS values measured with the digital Voltmeter and V is the calculated RMS voltage from the samples.

R can be calculated by dividing the Voltage and current values V/I in accordance with the principles discussed in the articles referenced above.

Once you have calibrated your measurements for V and I in your block of 60 samples, the articles above give you some direction as to how to calculate your power in Watts RMS in a loop.

  [1]: Search for "calculating rms watts from samples of voltage and current" via Google.


message:
Can I connect a servo directly to arduino uno without a transistor?

I am going to mount an ultrasonic sensor on the servo.

body:
The Arduino's GPIO pins can drive the signal of most model servos directly, without any extra transistors.

Driving a model servo signal input is not the main problem with driving servos from an Arduino.

The main problem is trying to use the Arduino's power supply to power the model servo. With many model servo's, the amount of current the model servo needs to start, or when it is almost stopped is so big that the Arduino's power supply can't maintain 5V. As the Arduino's power supply voltage drops, the Arduino often gets reset, and the program restarts from `setup`.


message:
Common/standard library and/or protocol for Arduino to be I2C slave for driving NeoPixel

I would like to control a string of WS2812/NeoPixels from a SBC like a BeagleBone or C.H.I.P. I realize someone has gone through the trouble to come up with a way to drive the WS2812 string from a BeagleBone directly with the PMU, but I would like to have an Arduino like a Pro Mini do the signal generation, while the SBC would direct the Arduino what to display.

I found the [node-pixel][1] setup with I2C backpack on the arduino, but it requires on the SBC side NodeJS, Johnny-Five and other libraries that I would have no other use for. It seems overkill.

Is there some commonly used protocol over I2C for controlling NeoPixels (with the arduino being the I2C slave), or will I be better off developing my own simple protocol?

On the SBC side, I would likely be coding either in C/C++ or Python.

  [1]: https://github.com/ajfisher/node-pixel

body:
You should break your project up into smaller parts.

0. Consider using other led strips, that can be driven directly. Consider using ready-made parts or opensource code (google).
1. Make an Arduino drive a NeoPixel Ledstrip. (Check adafruit libraries/NeoPixel guide)(Sanity/wiring check)
2. Communicate with Arduino and Beaglebone over I2C. Try sending "Hi" and respond "Ok".
3. Think of a protocol, how to indicate start/stop of a message.
4. Send the "color bytes" using said protocol.
5. Unpack the color bytes and put them in a pixel array (See NeoPixel library).
6. Run "ledstrip.show();”

Please atleast try to do these steps. If one fails, you can create a question with details on what you have tried or what isn't working.

Maybe "nodepixel" already has the Arduino code for you. You then only need to know what bytes to send over I2C, which you can do with any programming language that supports I2C access on your platform.


body:
If it helps simplify your project, I wrote a [small library](http://www.gammon.com.au/forum/?id=13357) that outputs to NeoPixels using the SPI hardware. The code to send one byte is simply this on the Atmega328P:

<!-- language: lang-c++ -->

    void sendByte (byte b)
      {
        // send one byte to the Neopixels - note that the "off" gap is partly handled by the loop overhead
        //   gaps measured empirically to be 1.7 µs to 2 µs, so we don't need to add any more of our own
        for (byte bit = 0; bit < 8; bit++)
          {
          if (b & 0x80) // is high-order bit set?
            SPI.transfer (0b11111100);  // 1 bit - 750 ns on + 250 ns off (acceptable "on" range 550 ns to 850 ns)
          else
            SPI.transfer (0b11100000);  // 0 bit - 375 ns on + 625 ns off (acceptable "on" range 200 ns to 500 ns)
          b <<= 1; // shift next bit into high-order position
        } // end of for each bit
    } // end of sendByte

One pixel is 3 bytes (green / red / blue):

<!-- language: lang-c++ -->

    void sendPixel (const byte r, const byte g, const byte b)
      {
      sendByte (g);        // NeoPixel wants colors in green-then-red-then-blue order
      sendByte (r);
      sendByte (b);
      } // end of sendPixel

The timing issue arises because the pixels "latch" if around 9µs elapses with no data. Thus you either precompute the data to be sent, or decide what to send very quickly.

---

Under the circumstances, using I2C, you would need to precompute the data, these is no way you could receive I2C on the fly and send it out to the Neopixels with them latching.

---

> Is there some commonly used protocol over I2C for controlling NeoPixels ?

Not that I am aware of. I suggest you either send the pixel data (which would be a lot, and have to be broken into smallish packets), or send a "pattern number" and have the receiver generate the data.

Be aware that the standard I2C library has a 32-byte buffer so you can't send hundreds of bytes in a single I2C transaction.


message:
How to reprogram Arduino if USB port is already in use?

I'm developing a keyboard emulator using Digispark Pro (based on Arduino) which uses USB port as the keyboard interface. I haven't programmed it yet because I doubt how should I recognize the chip to Arduino IDE again using USB port after programming the board.

So my question is, how to reprogram Arduino if USB port is already recognized as keyboard HID?

body:
https://digistump.com/wiki/digispark/tutorials/connectingpro
It is suggested that in order to upload using the Arduino IDE you must:

 - Add the repository `http://digistump.com/package_digistump_index.json` in Preferences > Additional Boards Manager URLs

 - Install Digistump from the boards manager.

 - select the DigiSpark in Tools > Boards.

 - Then this is perhaps the important bit "**You do not need to plug in your Digispark Pro before invoking upload**"   So hit upload before connecting the Digispark.

 - Then connect the Digispark when prompted by the Arduino IDE.


message:
How can I play music using a speaker and Micro SD card Module?

I am trying to play music using my Arduino and micro SD card module but can't seem to do it. Can anyone shed some light on this? The SD card module I'm using is a Catalex sainsmart micro SD card module. It has the outputs `VCC`, `GND`, `MISO`, `MOSI`, `CS`, and `SCK`. `VCC` is in `5v`, `GND` is in `GND`, `CS` is in `Pin 4`, `MISO` is in `Pin 12`, and `MOSI` is in `Pin 11`.

body:
Use an MP3 shield. This includes an SD card reader on the board. Many tutorials are available for this popular board. This shield makes it easier to program the Arduino.

https://www.sparkfun.com/products/12660


body:
> This Arduino project is one of the most simple and fun projects you
> can build with Arduino in 10-15 minutes. The result of this make will
> be an Arduino Audio Player which will play “.wav” files. It consist of
> a speaker, a simple transistor acting as an amplifier and a micro-SD
> card adapter with a micro-SD in it through which the .wav files are
> loaded and played.

https://diyhacking.com/arduino-audio-player/


message:
Why change the variable content?

I don't understand why change `uidList[reader]` variable, when doesn't run more to the else. I use in this test only the "0" reader.

First loop go to the "else" and fill the `uid` to `uidList[reader]`. (good)
Second loop go to the "if" because the two `uid` is equal.(good)

I remove NFC and place the other, but the `uidList[reader]` updated immediately to the new `UID`, not in the "else". Never go again to else. Why?

    #define NR_OF_READERS   2
    byte* uidList[NR_OF_READERS];
    MFRC522 mfrc522[NR_OF_READERS];   // Create MFRC522 instance.
    ......
    void loop() {
      ....
      delay(2500);
      for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {

         dump_byte_array(uidList[0], 8);
         dump_byte_array(uidList[1], 8);

       if (mfrc522[reader].PICC_IsNewCardPresent() &&     mfrc522[reader].PICC_ReadCardSerial()) {

         dump_byte_array(uidList[0], 8); //WHY UPDATED HERE???
         dump_byte_array(uidList[1], 8);

         if (uidList[reader] == mfrc522[reader].uid.uidByte) {

            Serial.println(F("Same NFC"));
            dump_byte_array(uidList[0], 8);
            dump_byte_array(uidList[1], 8);

         } else {

            Serial.println(F("Other NFC in this reader"));

            uidList[reader] = mfrc522[reader].uid.uidByte;

            dump_byte_array(uidList[0], 8);
            dump_byte_array(uidList[1], 8);

         }

       }
    }

    void dump_byte_array(byte *buffer, byte bufferSize) {
      for (byte i = 0; i < bufferSize; i++) {
        Serial.print(buffer[i] < 0x10 ? " 0" : " ");
        Serial.print(buffer[i], HEX);
      }
      Serial.println();
    }

When I placed the new NFC in the reader, this debug appear on serial monitor.

     DF 6D 05 D2 00 00 00 00 //old NFC uid it's good

     AB 00 6C 02 F0 21 00 00

     FF 2C 02 69 00 00 00 00 //WHY UPDATED HERE???

     AB 00 6C 02 F0 21 00 00

Same NFC

     FF 2C 02 69 00 00 00 00

     AB 00 6C 02 F0 21 00 00

Thanks any idea.

body:
Well, it's easy, as you are using pointers. If the original place gets changed, you can see changed value because you don't have your own copy.

Your `if` statement is also wrong, as you are comparing two pointers here. They will be different at the first time comparation, but after the assigment they are unlikely to change.

The solution is using:

    byte uidList[NR_OF_READERS][8]; // better to use some constant value instead of magic number

and `memcpy` for making a copy and `memcmp` for comparing its content. Both are from `<cstring>` include


message:
Does the Arduino Uno have two crystals?

Take a look at this picture:

[![][1]][1]

I think most of use agree that the "big silvery" thing on the board (red) is the famous 16 MHz crystal of the Arduino. That's what I've believed until very recently.

I was bored so I looked at my Arduino Uno, and saw that it has what seems like another crystal (yellow). It looks like the one that is on the Pro Mini. It's also located near the XTAL pins. After I inspected the schematic a second time, it also appears that there are two crystals on the board.

Which one out of those two is actually connected to the XTAL pins and why are there two?

  [1]: https://i.stack.imgur.com/oLeoJ.png

body: The **ceramic resonator** in yellow is connected to the main MCU, and the crystal in red is connected to the other MCU. USB requires tighter tolerances than is available from a resonator therefore a crystal must be used instead.


body: There are 2 that you can see, but there are **internal resonators** in both chips. You can use the ATMega328's one if it's on a breadboard (it's half the frequency tho), and much more temperature-dependent. Just need to give it a fresh bootloader.


message:
Thermosensor Error - 'Wire' does not name type?

Here is the code I am using:

    #define D6T_ID 0x0A
    #define D6T_CMD 0x4C

    int ReadBuffer[35];
    float ptat;
    float tdata[16];

    #include <Wire.h>
    void setup() {
      Wire.begin();
      Serial.begin(9600);
      delay(500);

    }

    void loop() {

    }
      int i;
      Wire.beginTransmission(D6T_ID);
      Wire.write(D6T_CMD);
      Wire.endTransmission();

      Wire.requestFrom(D6T_ID,35);

      for (i=0; i<35; ++i) {
        ReadBuffer[i] = Wire.read();
      }

      ptat = (ReadBuffer[0]+(ReadBuffer[1]*256))*0.1; //Reference Temp

      for (i=0; i<16; ++i) {
        tdata[i] = (ReadBuffer[(i*2+2)]+(ReadBuffer[(i*2+3)]*256))*0.1;
      }

      float tempF;

      if ( ((tdata[0]*9.0/5.0)+32.0)>0 )
      {
        for (i=0; i<16; ++i)
        {
          tempF = (tdata[i]*9.0/5.0)+32.0;
          Serial.print(tempF);
          Serial.print(',');
        }
        Serial.print((ptat*9.0/5.0)+32.0;
        Serial.print(',');
        Serial.println();
      }

        }
      }

This is the error I am getting:

exit status 1
'Wire' does not name a type

And it highlights this area of code:

    Wire.requestFrom(D6T_ID,35);

I am completely new to using the arduino and coding so I am not sure if I already have the wire library that this code requires but when I look at the libraries in the Tools menu it is there. Do I need to download another library? If so can someone send me the link? Can someone explain what the error means? This is all foreign to me.

Thank you

body: You've goofed up your braces and none of that code is in `loop()`. Look at the braces in the code and make the appropriate corrections.


body:
The reason for the error message is that your braces do not properly match, and the code that was meant to be inside `loop()` is not, but instead looks to the compiler like some new global declarations. Fix the syntax errors and your code will compile:

 - Remove the brace in line 18 that closes the loop() function prematurely,
 - Fix the missing ')' in line 46,
 - Remove line 52, an extraneous '}',