message:
Arduino Leonardo Upload issue with ubuntu 14.04

I got a bare conductive board ( which is based on arduino leonardo ) . I was trying to upload a blink sketch using arduion 1.5.7. But its always failing and here is the log. I never work a leonardo before. Any ideas what is happing with this ?

    Build options changed, rebuilding all

    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /tmp/build5447563659949358969.tmp/Blink.cpp -o /tmp/build5447563659949358969.tmp/Blink.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/wiring_analog.c -o /tmp/build5447563659949358969.tmp/wiring_analog.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/wiring_digital.c -o /tmp/build5447563659949358969.tmp/wiring_digital.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/wiring_shift.c -o /tmp/build5447563659949358969.tmp/wiring_shift.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/WInterrupts.c -o /tmp/build5447563659949358969.tmp/WInterrupts.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/hooks.c -o /tmp/build5447563659949358969.tmp/hooks.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/wiring_pulse.c -o /tmp/build5447563659949358969.tmp/wiring_pulse.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/wiring.c -o /tmp/build5447563659949358969.tmp/wiring.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HardwareSerial3.cpp -o /tmp/build5447563659949358969.tmp/HardwareSerial3.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/Tone.cpp -o /tmp/build5447563659949358969.tmp/Tone.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HardwareSerial1.cpp -o /tmp/build5447563659949358969.tmp/HardwareSerial1.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HardwareSerial2.cpp -o /tmp/build5447563659949358969.tmp/HardwareSerial2.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/Print.cpp -o /tmp/build5447563659949358969.tmp/Print.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HID.cpp -o /tmp/build5447563659949358969.tmp/HID.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/USBCore.cpp -o /tmp/build5447563659949358969.tmp/USBCore.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp -o /tmp/build5447563659949358969.tmp/HardwareSerial.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/IPAddress.cpp -o /tmp/build5447563659949358969.tmp/IPAddress.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/WMath.cpp -o /tmp/build5447563659949358969.tmp/WMath.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/WString.cpp -o /tmp/build5447563659949358969.tmp/WString.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/main.cpp -o /tmp/build5447563659949358969.tmp/main.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/HardwareSerial0.cpp -o /tmp/build5447563659949358969.tmp/HardwareSerial0.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/new.cpp -o /tmp/build5447563659949358969.tmp/new.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/Stream.cpp -o /tmp/build5447563659949358969.tmp/Stream.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_BARETOUCH -DARDUINO_ARCH_AVR -DUSB_VID=0x2A6E -DUSB_PID=0x8003 -DUSB_MANUFACTURER="Bare Conductive" -DUSB_PRODUCT="Touch Board" -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino -I/home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/variants/leonardo /home/achayan/Downloads/arduino-1.5.7/hardware/arduino/avr/cores/arduino/CDC.cpp -o /tmp/build5447563659949358969.tmp/CDC.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/wiring_analog.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/wiring_digital.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/wiring_shift.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/WInterrupts.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/hooks.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/wiring_pulse.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/wiring.c.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HardwareSerial3.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/Tone.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HardwareSerial1.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HardwareSerial2.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/Print.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HID.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/USBCore.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HardwareSerial.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/IPAddress.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/WMath.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/WString.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/main.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/HardwareSerial0.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/new.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/Stream.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-ar rcs /tmp/build5447563659949358969.tmp/core.a /tmp/build5447563659949358969.tmp/CDC.cpp.o
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-gcc -w -Os -Wl,--gc-sections -mmcu=atmega32u4 -o /tmp/build5447563659949358969.tmp/Blink.cpp.elf /tmp/build5447563659949358969.tmp/Blink.cpp.o /tmp/build5447563659949358969.tmp/core.a -L/tmp/build5447563659949358969.tmp -lm
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/build5447563659949358969.tmp/Blink.cpp.elf /tmp/build5447563659949358969.tmp/Blink.cpp.eep
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/build5447563659949358969.tmp/Blink.cpp.elf /tmp/build5447563659949358969.tmp/Blink.cpp.hex

    Sketch uses 4,798 bytes (16%) of program storage space. Maximum is 28,672 bytes.
    Global variables use 157 bytes (6%) of dynamic memory, leaving 2,403 bytes for local variables. Maximum is 2,560 bytes.
    Forcing reset using 1200bps open/close on port /dev/ttyACM0
    PORTS {/dev/ttyACM0, } / {} => {}
    PORTS {} / {} => {}
    PORTS {} / {/dev/ttyACM0, } => {/dev/ttyACM0, }
    Found upload port: /dev/ttyACM0
    /home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/bin/avrdude -C/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/build5447563659949358969.tmp/Blink.cpp.hex:i

    avrdude: Version 6.0.1, compiled on Apr  3 2014 at 21:52:43
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2009 Joerg Wunsch

             System wide configuration file is "/home/achayan/Downloads/arduino-1.5.7/hardware/tools/avr/etc/avrdude.conf"
             User configuration file is "/root/.avrduderc"
             User configuration file does not exist or is not a regular file, skipping

             Using Port                    : /dev/ttyACM0
             Using Programmer              : avr109
             Overriding Baud Rate          : 57600
             AVR Part                      : ATmega32U4
             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    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

             Programmer Type : butterfly
             Description     : Atmel AppNote AVR109 Boot Loader

    Connecting to programmer: .avrdude: Send: . [1b]
    avrdude: Send: S [53]
    avrdude: Recv: C [43]

    avrdude: ser_recv(): programmer is not responding
    avrdude: butterfly_recv(): programmer is not responding

And My dmesg output is

    [ 3616.984079] usb 4-2: new full-speed USB device number 11 using uhci_hcd
    [ 3617.155216] usb 4-2: New USB device found, idVendor=2a6e, idProduct=8003
    [ 3617.155224] usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
    [ 3617.155229] usb 4-2: Product: Touch Board
    [ 3617.155234] usb 4-2: Manufacturer: Bare Conductive
    [ 3617.158323] cdc_acm 4-2:1.0: This device cannot do calls on its own. It is not a modem.
    [ 3617.158359] cdc_acm 4-2:1.0: ttyACM0: USB ACM device
    [ 3617.166427] input: Bare Conductive Touch Board as /devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2:1.2/input/input22
    [ 3617.166675] hid-generic 0003:2A6E:8003.0007: input,hidraw1: USB HID v1.01 Mouse [Bare Conductive Touch Board] on usb-0000:00:1a.1-2/input2

And My lsusb output

    Bus 002 Device 002: ID 04f2:b179 Chicony Electronics Co., Ltd
    Bus 002 Device 004: ID 18d1:4ee2 Google Inc. Nexus 4 (debug)
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 007 Device 002: ID 03f0:171d Hewlett-Packard Bluetooth 2.0 Interface [Broadcom BCM2045]
    Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 004 Device 011: ID 2a6e:8003
    Bus 004 Device 002: ID 1d57:0008 Xenta
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

body:
Try the arduino.cc forums. Post your logs, and you MIGHT get an answer that'll work. The guys who developed the Leonardo got it to work with Ubuntu 10.04 without a special device driver. I use Ubuntu like you but not the magic 10.04 version and was forced to give up on the Leonardo despite heroic effort.

The problem is that 32u4 chip the Leonardo (and Micro) use. Instead of having a separate FTDI chip like a good ol' UNO, it handles USB on its own. With a bootloader on a Leonardo that enables only USB to be used (besides ICSP) Windows needs a funny .inf file to make it work. But Linux? In this case, Windows of a given version is Windows is Windows. Linux boxes are more like people in that each has its own personality, given the zillion distributions and versions thereof.

I'm convinced that the Leonardo developers merely got lucky with Ubuntu 10.04.


sender: user

message:
PWM generation using Registers

I'm using the Registers of the Arduino micro to get a signal for Electronic Speed Controllers (ESC) for brushless motors.
As far as I read, ESCs interpret everything they can, while just ignoring too fast update rates. If somebody knows better, this would be a great time to yell.

The goal is to get a digital signal, where a timespan between 1 and 2 ms is HIGH and the rest low. Ideally I want this at 50-400Hz, since 488Hz is the fastest possible frequency, and 50 Hz the standard Servo frequency.

I try to use Phase Correct Mode to count up and down continuously. As the value in the counter reaches my set OCRnx on the way up, it sets the output pin LOW, as it reaches the same value on the way down, after reaching TOP(value), it sets the output HIGH. In ATmega documentation terms, this is NON-inverted Phase-Correct-PWM.

So I set the Registers DDR (to set the pin as output), TCCR1A and TCCR1B and ICR1 (TOPvalue = between 20000 and 2500).

Now using OCR1A = 1000 should give me a pulse width of 1000ms. This is the expected or target behaviour.

My testing code is:

    // using a 16-bit timer to generate PWM signals for ESCs

    // Phase Correct Mode counts from Bottom to Top and back to Bottom
    // with a prescaler of 8
    // motor signal (OCRnx) uses values of 1000 (idle) - 2000 (max)
    // which directly corresponds to microseconds HIGH-time
    // setting the range to (BOTTOM) 0 - TOPvalue sets the frequency

    // two important formulas are:
    // frequency(PWM) = F_CPU / (2*Prescalar*TOPvalue)
    //
    // PulseWidth [s] = High-tick-count / (F_CPU/Prescalar)
    // High-tick-count = 2 * OCR-value

    // n = number of timer (1,3)
    // x = A,B,C

    #include "Arduino.h"
    // #include <Arduino.h>
    // #define DEBUG
    // #include <Moto.h>

    #define PRESCALAR 8
    #define PWM_FREQUENCY 50
    #define TOP_VALUE F_CPU/(2*PRESCALAR*PWM_FREQUENCY)

    uint16_t dutytime = 1000; // this gives idle throttle signal

    void setup(void) {
      Serial.begin(115200);
      // moto.setup();

      // TIMER 1
      // TIMSK1 = 0; // disable Interrupts for timer1
      DDRB |= (1<<DDB5); // D9 Output
      DDRC |= (1<<DDC6); // D5 Output

      // set 1000ms to start motors in idle mode
      OCR1A = 1000L;
      OCR3A = 1000L;

      // bits 7,5,3 PWM Output on pins A,B,C respectively
      // bits 1,0 WGM_1,0: phase correction mode
      // TCCR1A |= B10000010; // in hex: 0xAA for all 3 = B 1010 1010
      TCCR1A |= (1<<COM1A1)|(1<<WGM11);
      // bit 4,3 WGM_3,2: phase correction mode
      // bits 2,1,0 Prescalar: 8
      // TCCR1B |= B00010010; // in hex: 0x12; B 0001 0010
      TCCR1B |= (1<<WGM13)|(1<<CS11);
      ICR1 = TOP_VALUE;

      // TIMER 3
      // TIMSK3 = 0; // disable Interrupts for timer3
      // bit 7 PWM Output on pin A
      // bits 1,0 WGM_1,0: phase correction mode
      TCCR3A |= B10000010; // in hex: 0x82; // B 1000 0010
      // bit 4,3 WGM_3,2: phase correction mode
      // bits 2,1,0 Prescalar: 8
      TCCR3B |= B00010010; // in hex: 0x12; B 0001 0010
      ICR3 = TOP_VALUE; // TOPvalue = 2048

    }//setup

    void loop(void) {

      // Serial.println(TOP_VALUE);
      // delay(500);
      while (dutytime < 2000) {
        dutytime += 150;
        OCR1A = dutytime;
        OCR3A = dutytime;
        Serial.println(dutytime);
        delay(1500);
      }
      while (dutytime > 1000) {
        dutytime -= 150;
        OCR1A = dutytime;
        OCR3A = dutytime;
        Serial.println(dutytime);
        delay(1500);
      }

    }//loop

I repeated the settings for timer3 to get something to compare to. Both do give the same: if i delete the loop and just write `loop{}` nothing happens. The pins are high and seem to stay so. With the while loops activated, my multimeter gives me 1Hz (which are the changes of course) and between 99.9% duty cycle and 96%.
An led, which i connected to it blinks every second a very short time.

What am I doing wrong?

sender: assistant

body:
What I did wrong was using `|=` instead of `=` . Apparently Arduino set some of these Bits on start, which didn't change.
Now it works like a charm and I added a frequency choice, which works for at least 50,200,400,488 Hz. Everything in between should work aswell!

Working testcode for timer1 with serial input of HIGH-time:

    #define PRESCALAR 8
    #define PWM_FREQUENCY 50
    #define TOP_VALUE F_CPU/(2*PRESCALAR*PWM_FREQUENCY)

    uint16_t dutytime = 1000; // this gives idle throttle signal

    void setup(void) {
      Serial.begin(115200);

      // TIMER 1
      DDRB |= (1<<DDB5); // D9 Output

      // set 1000ms to start motors in idle mode
      OCR1A = 1000L;

      // bits 7,5,3 PWM Output on pins A,B,C respectively (COMnx1)
      // bits 1,0 WGM1(1,0): phase correction mode
      TCCR1A = B10000010; // in hex: 0xAA for all 3 = B 1010 1010
      // bit 4,3 WGM_3,2: phase correction mode
      // bits 2,1,0 Prescalar: 8
      TCCR1B = B00010010; // in hex: 0x12; B 0001 0010
      ICR1 = TOP_VALUE;
    }//setup

    void loop(void) {
      // Serial.println(TOP_VALUE);
      dutytime = serial_input();
      if (dutytime) {
        OCR1A = dutytime;
      }
      delay(500);
    }//loop

    float serial_input() {
      double num = 0;
      while(Serial.available()) {
        delay(2);
        char ser = Serial.read();
        if(isDigit(ser)) {
          num = (num*10)+(ser-48);
        }else{ break; }
      }
      if (num) {Serial.println(num);}
      return num;
    }


message:
While using Arduino Ethernet shield, do we need to explicitly select/Deselect SD and W5100 in our code?

It has been mentioned here http://arduino.cc/en/Main/ArduinoEthernetShield that corresponding libraries take care of chip select between SD and W5100 in Arduino Ethernet shield. Does it take care properly all the time? What happens if the Chipselect is not properly managed by libraries? Does that cause blocking of code?

body:
Here we have a nice example of a single Shield requiring TWO libraries. The Ethernet.h and SD.h where the later appears as an after thought and is not demonstrated by the Example. As it is done so in the SD examples. However, their styles are slightly different.

The Ethernet libary as mentioned (provided within) the IDE is hardcoded to implement the Chip Select for the W5100 on corresponding pin. When using the typical purchased Ethernet Shield, there is no need to configure it. Unlike the SD library, which requires the pin to configured using the SD.begin(4) member function.

    if (!SD.begin(4)) {
      Serial.println("initialization failed!");
      return;
    }

Where again on the typical Ethernet shield the SD card is at pin D4.

Note being hardcode that the Ethernet library selects the matching pin to corresponding shield.

    private:
    #if defined(ARDUINO_ARCH_AVR)
    #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
      inline static void initSS()    { DDRB  |=  _BV(4); };
      inline static void setSS()     { PORTB &= ~_BV(4); };
      inline static void resetSS()   { PORTB |=  _BV(4); };
    #elif defined(__AVR_ATmega32U4__)
      inline static void initSS()    { DDRB  |=  _BV(6); };
      inline static void setSS()     { PORTB &= ~_BV(6); };
      inline static void resetSS()   { PORTB |=  _BV(6); };
    #elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__)
      inline static void initSS()    { DDRB  |=  _BV(0); };
      inline static void setSS()     { PORTB &= ~_BV(0); };
      inline static void resetSS()   { PORTB |=  _BV(0); };
    #else
      inline static void initSS()    { DDRB  |=  _BV(2); };
      inline static void setSS()     { PORTB &= ~_BV(2); };
      inline static void resetSS()   { PORTB |=  _BV(2); };
    #endif
    #endif // ARDUINO_ARCH_AVR

And in the case of the UNO (or the else case) Port B Bit 2 is D10.

----------

worth noting that SD library has an alternate method of initializing and using the SD card

    if (!card.init(SPI_HALF_SPEED, chipSelect)) {
      Serial.println("initialization failed. Things to check:");

where chipSelect would be D10 in this case.


message:
Problem uploading to Arduino Yun

I have an Arduino Yun. I am trying to upload the code in Arduino but after I click on Upload, I get the error message shown in the image.

At first it showed the Arduino Yun under the port tab, after this message no Arduino is showing in port tab.
![enter image description here][1]

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

The portion of the error visible in the image:
>Couldn't find a Board on the selected port. Check that you have the correct port selected. If it is correct, try pressing the board's reset button after initiating the upload.

body: In the Arduino IDE, click on `Tools` (on the menu bar). Then, open the submenu `Board` and make sure "YUN" is selected.


body:
Seems like you havent chose the appropriate serial port.

Under tools, you'll also find serial port - make sure the appropiate one is selected.


message:
Arduino can't create file in sd card

I need to write and read some data from SD card. I link SD card(LC STUDIO) to Arduino (UNO). I use [this link][1] for create my project. In first day I don't have any problem and data correctly save to file. But now my circuit isn't work nicely. When Arduino is running the sketch I don't saw any error message.But when I link the SD card to my laptop, I don't saw any file on card!!
The code is here:

    #include <SPI.h>
    #include <SD.h>

    const int chipSelect = 10;

    File file;

    void setup()
    {
      Serial.begin(9600);
      while (!Serial) {
        ;
      }

      Serial.print("Initializing SD card...");
      pinMode(10, OUTPUT);

      if (!SD.begin(chipSelect)) {
        Serial.println("Card failed, or not present");
      }
      Serial.println("card initialized.");
      //creating file
      file = SD.open("test.txt",FILE_WRITE);
      file.close();
      //write data to file
      file = SD.open("test.txt",FILE_WRITE);
      if(file){
        file.println("OK!!");
        file.println("1");
        file.println("2");
        file.println("3");
        file.println("OK!!");
        file.close();
      }
    }
    void loop()
    {
    }
  [1]: http://www.instructables.com/id/Arduino-DIY-SD-Card-Logging-Shield/?ALLSTEPS

body:
If there is no file on the card, you must first create the "test.txt" file and put it in the main directory of your SD card. Your code doesn't create a file and I don't think you can even do that with the SD library. If you want to create a file, you are going to have to use the SDfat library. Also take out this part of your code :
    `file.close();`
    `file = SD.open("test.txt",FILE_WRITE);`

You are just opening, then closing, and then reopening.


body:
Thank you all...
I found solution for my problem.
The circuit and the sketch isn't any problem. But I saw [this][1] and I think problem is because of LC Studio's SD card. In previous circuit I connect 5v pin of SD card to 5v pin on arduino. But now I disconnect that and connect 3v3 pin on card to 3v3 on arduino.
Now it's work very nice. And I don't know "why?" . Any idea?

  [1]: http://forum.arduino.cc/index.php?topic=122947.0


message:
Debugger for Code::Blocks + Arduino

I am not very experienced in this, but I was wondering if Code::Blocks has a way of getting a debugger that runs for Arduino chips, specifically. I understand there is Arduino IDE for but does it allow debugging specific to those microcontrollers (Amtel and such)?

body:
Answer: Code blocks does not currently have an Arduino debugger. The Arduino IDE does not have a debugger.

There is an Arduino debugger in Atmel Studio using the Visual Micro plugin.

That said, you have to use Ms Windows to use Atmel Studio which might not be available to you.

The Visual Micro debugger is simple and uses usb so does not require additional hardware but as your experience grows you might also like to progress to fully blown hardware debug using the native Atmel Studio Tools

[Visual Micro debug in Atmel Studio][1]

[Atmel Studio Download][2]

![Arduino usb debugger][3]

  [1]: http://www.visualmicro.com/page/Debugging-for-Arduino.aspx
  [2]: http://www.atmel.com/tools/atmelstudio.aspx
  [3]: https://i.stack.imgur.com/1BV46.png


body:
If you are interested in on-board debugging or off-board debugging, you will need a programmer/debugger. I would recommend the Atmel [AVR Dragon][1]. Atmel AVR Dragon uses the Atmel Studio 6.2, which is a great IDE.

![AVR Dragon][2]

  [1]: http://www.atmel.com/tools/avrdragon.aspx
  [2]: https://i.stack.imgur.com/AXFgx.gif


message:
Arduino NRF24L01+ arduino to netmf transmit issue

I want to communicate between Arduino Mini Pro (china import) and a stm32f4 running netmf runtime. At the moment I'm able to communicate between SPI1 and SPI2 on the stm32 board.

After that I switched on the Arduino. I'm using the RF24 library and modified the GettingStarted sample to simply open pipes and send the same byte array again and again to the stm32.

It works for the first transmit but after that I did not receive any interrupts on the receiver side.

Both NRF24L01+ are power supplied by a breadboard power supply module which supplies 500ma (max USB bus). The Arduino is connected and power supplied by a CP2102 USB/Serial adapter.

NETMF Address: 0F0F0F0F0F
Arduino Address: 0F0F0F0F0E

As arduino uses little endian, I reverse the bytes on stm32 side before writing the address into the pipe. But I'm already unsure if I need that step (adding the Arduino address on netmf side).

Here's my Arduino code:

    #include <SPI.h>
    #include "nRF24L01.h"
    #include "RF24.h"
    #include "printf.h"

    RF24 radio(9,10);

    const int payload_size = 4;
    const char payload[] = "PING";

    void setup(void)
    {

        Serial.begin(57600);
        printf_begin();
        radio.begin();
        radio.enableDynamicPayloads();
        radio.setChannel(77);
        radio.setAutoAck(true);
        radio.setRetries(15,15);
        radio.setDataRate(RF24_2MBPS);
        radio.openWritingPipe((uint64_t)0x0F0F0F0F0FLL);
        radio.openReadingPipe(1,(uint64_t)0x0F0F0F0F0ELL);
        radio.stopListening();
        radio.printDetails();
    }

    void loop(void)
    {
        unsigned long time = millis();
        bool ok = radio.write( payload, payload_size );

        if (ok)
            printf("SUCCESS %lu...\n",time);
        else
            printf("fail %lu...\n",time);

        // Try again 1s later
        delay(1000);

    }

Here's my NETmf code

    NRF24L01Plus _module = new NRF24L01Plus();

    public override void Init()
    {
        _module.Initialize(SPI_Devices.SPI2, Pins.GPIO_PIN_D_8, Pins.GPIO_PIN_D_10, Pins.GPIO_PIN_B_12);
        _module.Configure(new byte[] { 0x0F, 0x0F, 0x0F, 0x0F, 0x0F }, 77, NRFDataRate.DR2Mbps);

        // both handlers are never executed
        _module.OnDataReceived += this.OnReceive;
        _module.OnInterrupt += _module2_OnInterrupt;

        _module.Enable();

    }

body:
I have a couple of projects that use the NRF24L01+ and the RF24 Library.

As I mentioned in my comment, the examples provided is not asynchronous. I am not sure if the library supports asynchronous operations. Nevertheless, in your example, one radio should be in transmit mode and the other receive. If you look at the examples, the author uses modes (role_ping_out and role_ping_back). Basicly, the author wrote the code so you can both send and receive. But you can't do send and receive at the same time.

If you look at the example cope in the library, you can see where you need to stop receiving and start sending:

    radio.stopListening();

    // Send the final one back.
    printf("Sent response.\n\r");
    radio.write( &got_time, sizeof(unsigned long) );

    // Now, resume listening so we catch the next packets.
    radio.startListening();

And on the other radio stop sending and start receiving:

    radio.startListening();

    // Wait here until we get a response, or timeout (250ms)
    unsigned long started_waiting_at = __millis();
    bool timeout = false;
    while ( ! radio.available() && ! timeout ) {
 __msleep(30); //add a small delay to let radio.available to check payload
      if (__millis() - started_waiting_at > 200 )
        timeout = true;
    }

    // Describe the results
    if ( timeout )
    {
      printf("Failed, response timed out.\n\r");
    }
    else
    {
      // Grab the response, compare, and send to debugging spew
      unsigned long got_time;
      radio.read( &got_time, sizeof(unsigned long) );

      // Spew it
      printf("Got response %lu, round-trip delay: %lu\n\r",got_time,__millis()-got_time);
    }

If this is a bit confusing, I would suggest you load the Getting Started example on both your radios. Once you get that working, you can get a better idea on how it works.

Good Luck


message:
How to use output from Arduino in C++ code?

I am a complete novice in Arduino and moderately experienced with the language C++. What if I want to use the output from the serial monitor in C++ code in real time?

Also how can I write to the serial monitor. Which libraries are available for this? Also please give me links to sites where I can learn more about this topic. I am using [Arduino Uno][1].

  [1]: http://arduino.cc/en/Main/ArduinoBoardUno

body:
Unfortunately, C++ doesn't have native support for serial I/O.

You could use the Windows API directly if you're feeling adventurous. It can be a little complicated to get to grips with, but not insurmountable. You can get basic information about it [here][1]. There's an example of using it with Arduino [here][2].

As an alternative, you could use a 3rd party library. [This one][3] looks good, although I haven't actually used it myself.

  [1]: http://msdn.microsoft.com/en-us/library/ff802693.aspx
  [2]: http://playground.arduino.cc/Interfacing/CPPWindows
  [3]: http://www.codeproject.com/Articles/992/Serial-library-for-C


body:
@Peter has already posted library links.

I recommend that you use [Node.js][1] ([node-serialport][2]) or [Python][3] ([serial][4]), which have excellent native serial support.

Both of these use C++ internally to communicate over Serial (Serial.h).
Try [going through the code][5] Node.js uses internally, and if you are willing to write that much, by all means use the library.

  [1]: http://en.wikipedia.org/wiki/Node.js
  [2]: https://github.com/voodootikigod/node-serialport
  [3]: http://en.wikipedia.org/wiki/Python_(programming_language)
  [4]: http://playground.arduino.cc/interfacing/python
  [5]: https://github.com/voodootikigod/node-serialport/tree/master/src


body:
    #include <windows.h>
    #include <string>
    #include <stdio.h>
    #define ARDUINO_WAIT_TIME 2000
    using namespace std;

    string portNumber;
    HANDLE hSerial;
    bool connected;
    COMSTAT status;

    bool connectPrinter(char *portName){

        //Connects to the port.
        hSerial = CreateFileA(portName,
        GENERIC_READ | GENERIC_WRITE,
        0,
        NULL,
        OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        NULL);

        if(hSerial==INVALID_HANDLE_VALUE)
        {
            if(GetLastError()==ERROR_FILE_NOT_FOUND){
                printf("ERROR: Handle was not attached. Reason: %s not available.\n", portName);
                return false;
            }
            else
            {
                //If port is in use by another program or did not closed previous process.
                printf("ERROR!!! \n");
                CloseHandle(hSerial);
                return false;
            }
        }
        else
        {

            DCB dcbSerialParams = {0};

            if (!GetCommState(hSerial, &dcbSerialParams))
            {
                printf("failed to get current serial parameters!");
                return false;
            }
            else
            {
                // Set Serial Port specifications.
                dcbSerialParams.BaudRate=CBR_115200;
                dcbSerialParams.ByteSize=8;
                dcbSerialParams.StopBits=ONESTOPBIT;
                dcbSerialParams.Parity=NOPARITY;

                 if(!SetCommState(hSerial, &dcbSerialParams))
                 {
                    printf("ALERT: Could not set Serial Port parameters");
                    return false;
                 }
                 else
                 {
                     connected = true;
                     printf("Connection Successful for :%s !!! \n" ,portName);
                     //Wait 2s as the arduino board will be reseting
                     return true;
                     Sleep(ARDUINO_WAIT_TIME);
                 }
            }
        }

    }

    int readData(char *buffer,unsigned int nbChar){

        DWORD bytesRead;
        DWORD dwCommModemStatus;

            //Set the type of data to be caught.(RXCHAR -> Data available on RX pin.)
            SetCommMask (hSerial, EV_RXCHAR );

            while (hSerial != INVALID_HANDLE_VALUE)
            {
              // Wait for an event to occur for the port.
              WaitCommEvent (hSerial, &dwCommModemStatus, 0);

              if (dwCommModemStatus & EV_RXCHAR )
              {
                    //unsigned int toRead;
                    //ClearCommError(this->hSerial, &this->errors, &this->status);
                    do
                    {
                      // Read the data from the serial port.
                        ReadFile (hSerial, buffer, 1, &bytesRead, 0);
                      // Display the data read.
                          printf ("%s" ,buffer);

                    } while (bytesRead > 0);
              }
            }
        //}
        //If nothing has been read, or that an error was detected return -1
        return -1;
    }

        int main()
        {

            char* buffer = new char[32768];
            int nbChar= 32768;
            string str="COMx"; // Use your port number to connect

            char * writable = new char[str.size() + 1];
            std::copy(str.begin(), str.end(), writable);
            writable[str.size()] = '\0';

            connectPrinter(writable);
            delete []writable;
            readData(buffer,nbChar);
            return 0;
        }

try this one, it should work. Comment below if it does not work. You might reset Arduino to read data in method `void setup()` in Arduino code. I recommend you to use C#, Java or Python for efficiency.


message:
Extract .hex from ATtiny45 using Arduino

As it is possible to program a ATtiny45 using Arduino as ISP Programmer, is there a way to backup an ATtiny45 program to a .hex file using Arduino?

body: Assuming the lock bits on the device haven't been set, sure. Simply prepare the Arduino for ArduinoISP, hook up the ATtiny45, and perform a read using AVRDUDE instead of a write (`-U flash:r:foo.hex:i`).


message:
Using IMU for a small Arduino and bluetooth support

I'm gonna start a project with an IMU with a bluetooth support inside a small board (mini or lillypad) and send datas to the mobile phone. But I'm quite new to those kind of technologies.

I'm going to choose a module for handling both operate voltage restriction and memory capacity for both library (IMU and bluetooth).

Any advice obj which arduino / IMU breakout / bluetooth module / battery to use? Or some similar projects?

body:
If you're new to Arduino I'd suggest avoiding the Mini and the BULLSH-fun that external programmers bring.
Something like the Pro Micro is much easier, almost as small, and less likely to bite.

Often the best way to pick hardware is to look for a tutorial (like [This] one) before deciding what to buy. While I personally haven't used IMUs it looks like the "6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345" from SparkFun would be (relatively) easy to use.

I've used the RN-41/2 Bluetooth modems (the same as are found in BlueSMiRF modules) and usually gotten on OK with them. There are plenty of tutorials available with a bit of Googleing.

[Adafruit] do a good line of Lipo batteries and chargers. They also have wireless charging modules if you're looking for extra brag-factor.

Hope this helps.

[This]: http://bildr.org/2012/03/stable-orientation-digital-imu-6dof-arduino/
[Adafruit]: http://www.adafruit.com/categories/138


message:
How do send sketch updates to devices without the editor?

I'd like to update the sketch of a device that a friend out of state is testing. I could have them install the full editor and send the source code but I'd rather not require them to do something so technical.

Is there a way to compile the firmware binary and push that out to a device over the COM port more directly?

body:
In general, yes.

The compile routine creates a .hex file in a temporary directory that contains the flash image for the device. One can use AVRDUDE to upload this .hex file to the Arduino from the command line. It is simply a matter of getting the command arguments correct in order to tell it where and how to upload the image. Enabling verbose output in the IDE will tell you both exactly where the .hex file is located and what arguments are required for the board selected.


message:
How can I stop SoftwareSerial from receiving data and re-enable it at some other point?

My project involves and RFID reader connected to an Arduino Pro Mini (5V, 16MHz) and an Adafruit CC3000 breakout WiFi chip. The device reads RFID tags and sends them to my web service. I am using Software Serial to read the RFID device data.

After I scan something, the Arduino tries to send the value that was read to the web service. This obviously causes a delay and the program only continues execution (i.e. next iteration of the loop() function) after the data has been sent.

My problem is simple. While the value is being sent, the serial buffer is can still accept scans from the RFID reader and on subsequent iterations, because there is data in the buffer the device attempts to send data again.

My question is how can I stop the software serial port from receiving data while I am trying to send data to the web service? Then when the data is sent successfully, how can I re-enable the software serial port from accepting data?

body:
Call [serial.end()](https://github.com/arduino/Arduino/blob/3a8ad75bcef5932cfc81c4746a87ddbdbd7e6402/libraries/SoftwareSerial/SoftwareSerial.cpp#L415-419) to stop receiving.

Then call `serial.begin(...)` again when you want to start listening again.


body: Whether or not the serial data becomes available really does not matter.  If you flush the port before every read rather than consuming the data, let 'er rip.  If you are using interrupts, toggle interrupts on the serial pin.


body:
According to [the docs](http://www.arduino.cc/en/Reference/SoftwareSerial), SoftwareSerial doesn't support `.end()`, so Gerben's answer won't work here, I think.

It's hacky, but you could exploit the fact that only one SoftwareSerial can receive data at a time, and create a second one, activating it with `SoftwareSerial.listen()`.  Then `.listen()` again on your original SoftwareSerial, when you want to resume listening.

Or, you could do as Marty Grogan says, and flush the read buffer before starting a new read.  Again, I don't think SoftwareSerial supports a flush method as such, so you'd need to just `.read()` until there's nothing `.available()`.


body:
The important parts are the `GPS.end()` which removes the interrupt routine and effectively stops listening to input although the data continues and the `GPS.begin(baud)` which reinstates the interrupt routine.  The other statements are program specific and could be anything that you want to do while the input data processing is off.

I am using it on a project where I smooth scroll time/date on an LED matrix but the SoftwareSerial interrupt routine makes the scrolling jerky.  I have reduced the NMEA sentences to just one but it still takes a noticeable amount of time to process it.  So the GPS is always on and sending but I only listen 4 times per hour by doing an `ss.begin()` for 5 second (or until valid data), save it then do the `ss.end()`.  Problem solved.  I get mildly jerky scrolling for 5 seconds but it is rarely noticed and my time is always right.

I will post the routine on my web site, [ILikeTheInternet.com][1], in a few days.

  [1]: http://www.iliketheinternet.com/


body:
I have successfully used two Software Serial interfaces by using the .listen() method.

    SoftwareSerial swSerial1(4,5);
    SoftwareSerial swSerial2(6,8);

    swSerial1.begin(9600);
    swSerial2.begin(9600);

At this point the Arduino is listening to swSerial2 because it was defined last. If I wanted to use swSerial1 in the loop I would call

    swSerial1.listen();

And switch back with

    swSerial2.listen();

This avoids the significant overhead of ending and re-beginning software serial connections.


body: Just a guess but I believe the current version of SoftSerial actually uses PCINT to detect the individual bits. I believe if that were disabled you would stop reception. It will take some work to get it to work without problems. This is just a guess.


message:
How to wait for next n bytes in I2C exchange?

I'm trying to get data from a sensor, but don't see how I can get data back. I'm looking at the data on the I2C bus with a logic analyzer, and I'm sending what I expect, but I seem to cut off the slave before he can respond.  My understanding from the [datasheet][1] is that I need to send this command to wake it up and request a measurement:

`0xD8 0x30 0x0A`

and then I need to send this command to get the data:

`0xD8 0x06 0xD9`

    #define HEARTBEAT_PIN            (13)

    #define 7BIT_ADDR                (0x6C)
    #define ADDR_WRITE               (0xD8)
    #define ADDR_READ                (0xD9)

    #define MAX_NUM_RX_BYTES         (8)
    #define MAX_NUM_TX_BYTES         (8)

    static uint8_t tx_buffer[MAX_NUM_TX_BYTES];
    static uint8_t rx_buffer[MAX_NUM_RX_BYTES];
    static uint8_t new_rx_data;

    void setup(void) {
      // Clear any module memory
      memset(tx_buffer, 0, MAX_NUM_TX_BYTES);
      memset(rx_buffer, 0, MAX_NUM_RX_BYTES);
      new_rx_data = false;

      Wire.begin();
    }

    void loop(void) {
      RequestMeasurement();
      delay(10);
      GetData();
      delay(500);
    }

    void RequestMeasurement(void) {
      // MR: 0xD8 0x30 0x0A
      // Internal (to IC) register address?
      tx_buffer[0] = 0x30;
      // Request-measurement command
      tx_buffer[1] = 0x0A;
      Wire.beginTransmission(7BIT_ADDR);
      Wire.write(tx_buffer, 2);
      Wire.endTransmission(true);
    }

    void GetData(void) {
      // GD: 0xD8 0x06 0xD9 0x?? 0x?? 0x?? 0x?? 0x?? (0x?? => slave data)
      // Slave address + 'write' indication bit
      // Internal (to IC) register address?
      tx_buffer[0] = 0x06;
      // Slave address + 'read' indication bit
      tx_buffer[1] = ADDR_READ;

      Wire.beginTransmission(7BIT_ADDR);
      Wire.write(tx_buffer, 2);
      Wire.endTransmission(true);

      // HOW DO I LEAVE THE BUS OPEN LONG ENOUGH
      // FOR THE SLAVE DEVICE TO RESPOND WITH THE DATA?
      //Wire.requestFrom(7BIT_ADDR, 3, true);
    }

  [1]: http://www.consensic.com/DataSheet/DAT-0007, rev0.1 CPS121 Data Sheet.pdf

body:
In the diagram there is a `S` after sending `0x60`. You first write to the device, letting it you want to read, and then you start reading.

I think you need to do something like

    void GetData(void) {
      Wire.beginTransmission(7BIT_ADDR);
      Wire.write(0x06);
      Wire.endTransmission(false);//don't terminate connection

      Wire.requestFrom(7BIT_ADDR, 3);//this will send the 0xD9
      pressure = ( (uint32_t) i2cread() << 16) | ( i2cread() << 8 ) | i2cread();//or something

    }

But I've never used I2C.


body:
First off; when talking about I2C bus, an important point to clarify: did you connect pullup resistors to both **SDA** and **SCL** lines (`A4` and `A5` respectively)? Without those, the I2C bus will not work properly.

Next, I2C protocol is quite low-level and a bit complex; but fortunately, the **Wire** library that comes with Arduino helps a lot and hides some of this complexity.

When using Wire library, there is a first point to keep in mind:

The device address is 7 bits only, the 8th bit is used to define the direction of data (read or write). You don't need to care about this direction bit as Wire deals with it for you.

In your situation, the device address is `0x6C`, ie `1101100` in binary.

The commands you mentioned that you want to send to the device, `0xD8 0x30 0x0A` and `0xD8 0x06 0xD9` already include the device address and the write bit (`0`):

`0xD8` is `1101 1000` ie `1101100` plus the `0` direction bit at the end.

Please note that `0xD8 0x06 0xD9` is made of 2 commands actually:

- `0xD8 0x06` is a write command to tell the device hich register we want to read
- `0xD9` is just the device address followed by the read bit (`1`): this is the way the I2C master tells a slave that the former will now wait for data sent from the latter.

It is important to split this command in 2 because each will use a specific API from Wire library.

Writing to your device with the Wire library will be done this way:

    // First command: start measurement
    Wire.beginTransmission(0x6C);
    Wire.write(0x30);
    Wire.write(0x0A);
    Wire.endTransmission();

    // Second command: tell the device what register we want to read
    Wire.beginTransmission(0x6C);
    Wire.write(0x0A);
    Wire.endTransmission();

Then you can start reading from your device with a different API:

    Wire.requestFrom(0x6C, 3);
    byte b1 = Wire.read();
    byte b2 = Wire.read();
    byte b3 = Wire.read();
    // Now rebuild value from the 3 bytes just read...

Note that `Wire.requestFrom(0x6C, 3);` will send the `0xD9` that is calculated from the device address `0x6C` and the read bit. SO you don't have (and you should not) send `0xD9` yourself, Wire doesit for you.

Please note that I use `Wire.endTransmission()` without the `stop` argument. Not sure if this is mandatory, but it worked fine on my I2C experiments.


body:
Ensure pullups (see datasheet for min acceptable resistance) are on I2C lines.

What I didn't understand at first was where the Wire library would bit shift and add read/write indication bits.  And those start/stop booleans.  After some testing and a closer read of the docs, I got this to work:

    #include "Wire.h"

    #define BAR_7BIT_ADDR         (0x6C)
    #define MAX_NUM_RX_BYTES      (5)
    #define MAX_NUM_TX_BYTES      (3)
    #define FIRST_TEMP_BYTE_INDEX (3)

    uint8_t new_rx_data;
    uint8_t tx_buffer[MAX_NUM_TX_BYTES];
    uint8_t rx_buffer[MAX_NUM_RX_BYTES];

    void setup(void) {
      Serial.begin(57600);
      Wire.begin();
    }

    void loop(void) {
      // If new data is available
      if (new_rx_data) {
        new_rx_data = false;

        // Process the data in the background
        PrintRxData();
      }

      BAR_RequestMeasurement();
      BAR_GetData();

      // This is a bit of a hack to get this function to execute.
      // After attempting to register this function as a callback with
      // the Wire.onReceive() method the function wouldn't execute.
      BAR_OnDataReceived(0);

      // Wait a tit, then do it again
      delay(500);
    }

    void RequestMeasurement(void) {
      // MR: 0xD8 0x30 0x0A
      // Internal (to IC) register address
      tx_buffer[0] = 0x30;
      // Request-measurement command
      tx_buffer[1] = 0x0A;
      Wire.beginTransmission(BAR_7BIT_ADDR);
      Wire.write(tx_buffer, 2);
      Wire.endTransmission(true);
    }

    void GetData(void) {
      // GD: 0xD8 0x06 0xD9 response from slave
      // Internal (to IC) register address
      tx_buffer[0] = 0x06;
      Wire.beginTransmission(BAR_7BIT_ADDR);
      Wire.write(tx_buffer, 1);
      Wire.endTransmission(false);
      Wire.requestFrom(BAR_7BIT_ADDR, 5, true);
    }

    void OnDataReceived(int num_bytes) {
      uint8_t i = 0;
      while (Wire.available() && i < MAX_NUM_RX_BYTES) {
        rx_buffer[i++] = Wire.read();
      }

      // Indicate to the background that there is new rx data
      new_rx_data = true;
    }

    void PrintRxData(void) {
      Serial.print("Pressure [kPa]: ");
      Serial.print(ToKpa(rx_buffer));
      Serial.print("\r\n");

      Serial.print("Temperature [C]: ");
      Serial.print(ToCelsius(&rx_buffer[FIRST_TEMP_BYTE_INDEX]));
      Serial.print("\r\n");
    }

    // Returns the pressure in kPa given raw binary data
    float ToKpa(uint8_t* raw_data) {
      // example: raw_data[3] = {0x63, 0x6C, 0xBB}; => 101.81kPa
      // return ((float)((((uint32_t)raw_data[0]) * 65536) |
      //                  (((uint32_t)raw_data[1]) * 256)  |
      //                  (((uint32_t)raw_data[2]) * 1))) / 64.0 / 1000.0;
      return ((float)((
                      (((uint32_t)raw_data[0]) << 16) |
                      (((uint32_t)raw_data[1]) << 8)  |
                      (((uint32_t)raw_data[2]) << 0)
                      ) >> 6)) / 1000.0;
    }

    // Returns the temperature in Celsius given raw binary data
    float ToCelsius(uint8_t* raw_data) {
      // example: raw_data[2] = {0x18, 0xE6}; => 24.90C
      // return ((float)(((uint32_t)raw_data[0]) * 256) + (((uint32_t)raw_data[1]) * 1)) / 256.0;
      return ((float)(
                     (((uint32_t)raw_data[0]) << 8) |
                     (((uint32_t)raw_data[1]) << 0)
                     )) / 256.0;
    }


message:
Simple compiler design help: Variable length arrays in Arduino?

I'm trying to write a simple compiler in the Arduino language that I am making up for my lab.  The compiler will have to be able to turn a string like this:

    "do command_one 3 times"

into a data structure that represents this:

    <command_one>, <command_one>, <command_one>

it should also be able to turn something more complicated like this:

    "do do c_one do c_two 2 times 2 times c_thr 2 times"

into a data structure that represents this:

    <c_one> <c_two> <c_two> <c_one> <c_two> <c_two> <c_thr> <c_one>
                    <c_two> <c_two> <c_one> <c_two> <c_two> <c_thr>

Another function will then read the commands out one by one.

These examples show all of the functionality that I would want from the compiler.

I'm having design issues for the compiler that I want to create.  Initially, I just wanted to do some string manipulation and turn the input string into an array of integers representing commands.  However, since the compiler will be outputting an arbitrarily large number of commands, and since arrays in Arduino need to be initialized with a length, this could be a problem.

I am not fluent in Arduino so I am hoping that an Arduino whiz can show me a quick solution.  I have already come up with the suggested solution on my own in Python, however, my solution in Python has to do with the ability to change the length of lists on the fly.

You will also notice that I posted the [same question](https://stackoverflow.com/questions/26303582/simple-compiler-design-help-variable-length-arrays-for-c) in the C++ stackexchange.  I am trying to write the same code for an Arduino and in C++.  I know that Arduino code is based on C++, if the answer is the same in Arduino as it is in C++ that would be very helpful.

body:
 1. The Arduino IDE features nearly full C++ *language* support (at least for C++03 features).
 2. *library* support is limited, but any standard component you need, you should be able to get an open source implementation that compiles.
 3. That said, you have **2K** of RAM to work with on an Arduino, so the kind of C++ code you would write for a general purpose computer just won’t get you very far.
 4. I could be wrong, but I very much doubt there are full Python implementations for Arduino.

**Edit:** Thanks to Mr. Penguin for pointing out that we’re dealing with an Arduino Due, not an Uno (I had overlooked the OP’s tag). 96K of memory is actually a decent amount to play with, so grab a library implementation like [this one](https://github.com/maniacbug/StandardCplusplus) and use the C++ techniques you wish to use.


body:
You question isn't totally clear to me, so this is just a pile of advice:

 - I think that you *might* be looking for a `run()` type of command, where you can run any function in code. However, since C++ is a *compiled* language, this is not possible. You can only do this in scripting languages.
 - Besides that, you want a variable length array? I haven't been able to confirm that this works with Arduino, but I know in standard C++ it is called *dynamic memory allocation* and you can do this with a pointer.
 - As for the string to store your data, where you're heading is wrong if you care about efficiency. I'd go with an array of integers (`unsigned int myData[2] = {1, 290};`) since you can store a *lot* more data in two bytes than you could typing out the function names.

For the "multiple run" function of your language, a simple for loop might work better to save space:

    for(int x = 5; x <3; x++) {
      //Code here
    }

****
Another thing you might want to do is store this "code" on a SD card encoded in two characters to yield a number like this:

    byte valOne = SD.read();
    byte valTwo = SD.read();
    int outputVal = (valOne << 8) + valTwo;

This would solve the whole variable array crisis in the first place.

*End of unorganized thoughts...*


body:
You may have more luck investigating standard C ways of dealing with this issue, instead of the common C++ methods.

Although it is typically not advised, you can use malloc and free on the Arduino. This allows you to dynamically use memory. I would provide a more detailed code example than below but when using dynamic memory it can be hard to troubleshoot what is going on without the use of a library to simplify the process. I would strongly advise doing a little study and understanding both dynamic memory management, and the repercussions of doing so on the Arduino platform. A solid foundation in this will pay off tenfold in time saved when debugging.

Note that you should check each time that you call malloc that it is successful

These resources might help:

 - [Dynamic Arrays][1]

 - [Check Malloc Succeded][2]

 - [Malloc and Free on Arduino Discussion][3]

 - [Is it a bad idea?][4]

Simple Example:

    // Make a pointer to your array
    someType *A;

    // The size of your array, may be changed programmatically.
    int arraySize = 5;

    // Reserve memory for your array.
    A = malloc(arraySize * sizeof(someType));

    // Use Array
    A[0] = someData;

    // Release A's memory when complete.
    free(A);

  [1]: http://forum.codecall.net/topic/51010-dynamic-arrays-using-malloc-and-realloc/
  [2]: https://stackoverflow.com/questions/5607455/checking-that-malloc-succeeded-in-c
  [3]: http://forum.arduino.cc/index.php?topic=37796.0
  [4]: https://arduino.stackexchange.com/questions/682/is-using-malloc-and-free-a-really-bad-idea-on-arduino


message:
How do you wire a ssr relay to a arduino nano

I am trying to wire a fss1-102z 5v ssr relay to my arduino nano but i cant get it to work here is my circuit. It stays stuck on and i cant get it to turn off.

![enter image description here][1]

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

Bluetooth control code

    char val;         // variable to receive data from the serial port
    int ledpin = 2;  // LED connected to pin 2 (on-board LED)

    void setup()
    {
      pinMode(ledpin = 2, OUTPUT); // pin 2 (on-board LED) as OUTPUT
      pinMode(ledpin = 3, OUTPUT); // pin 3 (on-board LED) as OUTPUT

        Serial.begin(9600);       // start serial communication at 115200bps

    }

    void loop()

    {
      if( Serial.available() )       // if data is available to read
      {
        ;
      }
      val = Serial.read();         // read it and store it in 'val'

      if( val == 'a' )               // if 'a' was received led 2 is switched off
      {
        digitalWrite(ledpin = 2, HIGH);    // turn Off pin 2
      }

      if( val == 'A' )               // if 'A' was received led 2 on
      {
        digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
      }

      if( val == 'b' )               // if 'b' was received led 3 is switched off
      {
        digitalWrite(ledpin = 3, HIGH);    // turn Off pin 3
      }

      if( val == 'B' )               // if 'B' was received led 3 on
      {
        digitalWrite(ledpin = 3, LOW);  // turn ON pin 3
      } //else (ledpin = 3, LOW)        //set led pin 3 to low state

      if( val == 'C' )               // if 'C' was received led 2 on for 1 second
      {
        digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
        delay(1000);                     // wait 1 second
        digitalWrite(ledpin, HIGH);      // turn Off pin 2
      }

      if( val == 'D' )               // if 'D' was received led 3 on for 1 second
      {
        digitalWrite(ledpin = 3, LOW);  // turn ON pin 3
        delay(1000);                     // wait 1 second
        digitalWrite(ledpin, HIGH);      // turn Off pin 3
      }

      if( val == 'E' )               // if 'E' was received led 2 on for 5 seconds
      {
        digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
        delay(5000);                     // wait 500 milli seconds
        digitalWrite(ledpin, HIGH);      // turn Off pin 2
      }

      if( val == 'F' )               // if 'F' was received led 3 on for 5 seconds
      {
        digitalWrite(ledpin = 3, LOW);  // turn ON pin 3
        delay(5000);                     // wait 500 milli seconds
        digitalWrite(ledpin, HIGH);       // turn Off pin 3
      }

      if( val == 'G' )               // if 'G' was received turn led pin 2 on for 500ms then switch off and turn on pin 3 for 500 mili seconds then off
      {
        digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
        delay(500);                     // wait 500mili second
        digitalWrite(ledpin, HIGH);      // turn Off pin 2
        digitalWrite(ledpin = 3, LOW);  // turn ON pin 2
        delay(500);                     // wait 500 mili second
        digitalWrite(ledpin, HIGH);      // turn Off pin 2
      }

      if( val == 'h' )               // if 'h' was received switch off all pins
      {
        digitalWrite(ledpin = 13, LOW);    // turn Off pin 13
        digitalWrite(ledpin = 2, HIGH);      // turn Off pin 2
        digitalWrite(ledpin = 3, HIGH);      // turn Off pin 3
    }

      if( val == 'H' )               // if 'H' was received switch pin 2 on and off 1000 times

      for(int i = 0; i < 1000; i++)
      {
        digitalWrite(ledpin = 2, HIGH);  // turn ON pin 2
       delay (1000); //wait 1000 mili seconds
        digitalWrite(ledpin = 2, LOW);  // turn Off pin 2
       delay (1000); //wait 1000 mili seconds

      }

    }

body:
 - Is it really 5v relay?
 - Need your code.
 - Check your output is really 5v.

You do a lot of mistakes:

    Int ledPin2=2;
    Int ledPin3=3;
    ...
    pinMode(ledPin2,OUTPUT);
    pinMode(ledPin3,OUTPUT);
    ...
    digitalWrite(ledPin2,HIGH);

I am on way now. I will edit and my answer when get back. Now correct your code

**EDIT**

You should improve your code... I edited it with switch cases. Also edit your comments because they are wrong!!! In the end there is `Serial.printout` states of pins. If you want uncomment them.

Here is the edited code:

    char val;         // variable to receive data from the serial port
    int ledpin2 = 2, ledpin3 = 3, ledpin13 = 13;  // LED connected to pin 2 (on-board LED)
    bool status = true;

    void setup()
    {
      pinMode(ledpin2, OUTPUT); // pin 2 (on-board LED) as OUTPUT
      pinMode(ledpin3, OUTPUT); // pin 3 (on-board LED) as OUTPUT
      pinMode(ledpin13, OUTPUT);
      Serial.begin(9600);       // start serial communication at 115200bps

    }

    void loop()

    {
      if( Serial.available() )       // if data is available to read
      {
      val = Serial.read();         // read it and store it in 'val'
      switch (val){
        case 'a':
        digitalWrite(ledpin2, HIGH);    // turn ON pin 2
        status = true;
        break;

        case 'A':
        digitalWrite(ledpin2, LOW);
        status = true;
        break;

        case 'b':
        digitalWrite(ledpin3, HIGH);
        status = true;
        break;

        case 'B':
        digitalWrite(ledpin3, LOW);
        status = true;
        break;

        case 'C':
        digitalWrite(ledpin2, LOW);  // turn OFF pin 2
        delay(1000);                     // wait 1 second
        digitalWrite(ledpin2, HIGH);      // turn ON pin 2
        status = true;
        break;

        case 'D':
        digitalWrite(ledpin3, LOW);  // turn OFF pin 3
        delay(1000);                     // wait 1 second
        digitalWrite(ledpin3, HIGH);      // turn ON pin 3
        status = true;
        break;

        case 'E':
        digitalWrite(ledpin2, LOW);       // turn OFF pin 2
        delay(5000);                      // wait 500 milli seconds
        digitalWrite(ledpin2, HIGH);      // turn ON pin 2
        status = true;
        break;

        case 'F':
        digitalWrite(ledpin3, LOW);  // turn ON pin 3
        delay(5000);                     // wait 500 milli seconds
        digitalWrite(ledpin3, HIGH);       // turn Off pin 3
        status = true;
        break;

        case 'G':
        digitalWrite(ledpin2, LOW);  // turn ON pin 2
        delay(500);                     // wait 500mili second
        digitalWrite(ledpin2, HIGH);      // turn Off pin 2
        digitalWrite(ledpin3, LOW);  // turn ON pin 2
        delay(500);                     // wait 500 mili second
        digitalWrite(ledpin3, HIGH);      // turn Off pin 2
        status = true;
        break;

        case 'h':
        digitalWrite(ledpin13, LOW);    // turn Off pin 13
        digitalWrite(ledpin2, HIGH);      // turn Off pin 2
        digitalWrite(ledpin3, HIGH);      // turn Off pin 3
        status = true;
        break;

        case 'H':
        for(int i = 0; i < 1000; i++)
      {
        digitalWrite(ledpin2, HIGH);  // turn ON pin 2
        delay (1000); //wait 1000 mili seconds
        digitalWrite(ledpin2, LOW);  // turn Off pin 2
        delay (1000); //wait 1000 mili seconds
      }
      status = true;
        break;
      }
      }

      /* Print out state of pin */
      /*
      if (status) {
       Serial.print("ledpin2 = ");
       Serial.print(bitRead(PORTD,2));
       Serial.print(" ,ledpin3 = ");
       Serial.print(bitRead(PORTD,3));
       Serial.print(" ,ledpin13 = ");
       Serial.println(bitRead(PORTD,7));
       status = false;
      }*/
    }


body:
According to its [datasheet][1], the `FSS1-102Z` doesn't work with DC-voltage. Also the minimal voltage required is 50VAC. Here is the excerpt from the datasheet:

![enter image description here][2]

  [1]: http://www.ateco.it/pdf/art058_fss1.pdf
  [2]: https://i.stack.imgur.com/TudEW.png


message:
Adjust resistance of a circuit

I need to emulate a component that measures an input mechanically and varies resistance from 0 to infinity (a more detailed set of specs list it at 20-1,000ohms, though I'll have to actually check its true values myself once I have physical access to it).

My aim is to replace this troublesome mechanical component with a current (read as available and serviceable) component, and convert the signal from the new component into an emulated signal (varying resistance) from the old component.

I am not certain as to the resolution required (how big the steps can be), though it may be able to handle 50ohm 'leaps', just judging by the range of mechanical movement and my past experience with replacing similar mechanical systems with ready-made kits for conversions.  I'd like to smooth the curve a whole lot more than 50ohm leaps though.

I have barely an idea where to begin on this.  I thought maybe a resistor ladder and a set of transistors triggered by the arduino to connect into the different points in the line, though I suspect there has to be a better way to achieve a much better result (and I don't think I have enough outputs for that anyway).

Is there a digital component that can vary its resistance using a PWM signal or maybe an analog signal from an arduino?

FYI, I greatly appreciate your input.

**EDIT**

The controller provides a constant voltage to the component, and the controller then looks at the ground (the voltage over a static resistor) I presume. It is an actual load.

I may be able to provide a variable voltage to the controller on its ground pin, though I have never seen that done on them before. I think that may be the trick, though the controller may(??) dislike it? I can try that.. The next best thing (only 2nd because it requires more components) would be the digital pot.

Anyone ever forged a return signal on a circuit thats supposed to supply its own constant voltage to a resistor type sensor?

body:
What about a digital potentiometer
[Digital Pot][1]

  [1]: http://en.wikipedia.org/wiki/Digital_potentiometer
Many types available, generally controlled via a serial interface e.g SPI


body: A JFET can act as a voltage-controlled resistor. It will need additional components if you require precision (a shunt resistor and a couple of op amps come to mind), but it should do. JFETs are rarer than they used to be, but still should be available for a few decades.


message:
I can't scroll Arduino IDE's example & scketch lists down

I have Arduino IDE 1.0.5 in win7 x64. I have so many library units. A pity that I can't scroll down to my other options. Is it Arduino.exe's problem or something else? How can I add triangle to scroll down and scroll up to see whole Sketchbook and Examples list? Thanks.

![enter image description here][1]

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

body:
You can get to the examples in Explorer. Just go to `My Documents`\ `Arduino`\ `libraries`\ `<library-name>`\ `examples`.

This one made me chuckle. Thank you for sharing.


body:
Try using 1.5.+. It has scroll arrows to allow larger lists of menus, bigger than the screen.

I find that most, if not all, sketches work equally well, if not better.

Up to 1.5.6r2 uses the same version of compiler as 1.0.+'s. 1.5.7 and newer uses a new compiler, that is more sctrict. All stock libraries work. And well written 3rd parties work. I personally use 1.5 and test backwards to 1.0.

There is a fork of 1.0 called ERW that has the scrolling. But 8t is becoming obsolete.


message:
What does the line "while (! Serial);" do in an Arduino program?

I'm new to Arduino, and I am trying a couple of tutorials. What does this line do in a program?

    while (! Serial);

body:
On boards with an FT232 chip or other USB->Serial bridge chip (Uno, Mega, etc) it does absolutely nothing.

On boards with a direct USB connection, such as the Leonardo or the Yùn it waits for an active serial connection to be established by the PC (i.e., for the serial port to be opened by a piece of software).

When you open the serial port of a board like the Uno or Mega the whole board usually resets*, so opening the serial port allows you to see the first bits of the serial data.  On the Leonardo etc it doesn't reset when you open the serial, so any serial output during the setup() function would be missed.  Adding that line makes the board pause until you open the serial port, so you get to see that initial bit of data.

*) Unless you specifically write some software that doesn't assert DTR when you open the port


message:
Cannot send two arguments from a WebClient

I am using the Arduino WifiWebClient to insert records into a RoR (Ruby on Rails) app. It works but it only inserts one field regardless of the number of arguments I send.

For example, if I test with Curl

    curl -d "sale[itemId]=1234&sale[machineId]=4567"  http://myapp.herokuapp.com/sales

It will create a Sale record and populate both fields itemId and machineId. Everything OK.

But when I send the following instruction from the Arduino, it will only populate the first field:

(I am only including the POST method to simplifly the code, the rest of the code is similar to http://arduino.cc/en/Reference/WiFiClient)

    void sendPOST() //client function to send/receive POST request data.
    {
    if (client.connect(URL,PORT)) {  //starts client connection, checks for connection
    Serial.println("connected");

    Serial.println("POST /sales HTTP/1.1"); //download text
    Serial.println("From: Arduino1");
    Serial.println("Host: evening-sierra-3769.herokuapp.com");
    Serial.println("User-Agent: HTTPTool/1.1");
    Serial.println("Connection: close");
    Serial.println("Cache-Control : no-cache");
    Serial.println("Pragma: no-cache");
    Serial.println("Expires: -1");
    Serial.println("Content-Type: application/x-www-form-urlencoded");
    Serial.print("Content-Length: ");
    Serial.println(31);
    Serial.println();
    Serial.println("sale[machineId]=\"09876543211234\"");
    Serial.println("sale[itemId]=\"09876543211234\"");
    Serial.println();

    client.println("POST /sales HTTP/1.1"); //download text
    client.println("From: Arduino1");
    client.println("Host: evening-sierra-3769.herokuapp.com");  // Will be needed if apache is configured for VHOSTS
    client.println("User-Agent: HTTPTool/1.1");
    client.println("Connection: close");
    client.println("Cache-Control : no-cache");
    client.println("Pragma: no-cache");
    client.println("Expires: -1");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.print("Content-Length: ");
    client.println(31);
    client.println();
    client.println("sale[machineId]=09876543211234\r\n");
    client.println("sale[itemId]=09876543211234\r\n");
    client.println();

    Serial.println("ARDUINO: HTTP message sent");
    delay(3000);
    if(client.available())
    {
      Serial.println("ARDUINO: HTTP message received");
      Serial.println("ARDUINO: printing received headers and script response...\n");

      while(client.available())
      {
        char c = client.read();
        Serial.print(c);
      }
    }
    else
    {
      Serial.println("ARDUINO: no response received / no response received in time");
    }

    client.stop();
    }

body:
Solved!

Changed the following lines:

    client.println("Content-Type: multipart/form-data");
    client.print("Content-Length: ");
    client.println(63);
    client.println();
    client.println("sale[itemId]=123456789012341234&sale[machineId]=123456789012341234\r\n");
    client.println();


message:
IRremote library and Moteino

Does somebody know if the [IRremote library][1] is compatible with Moteino boards?

If not, do you know a cheap solution to build a IR-remote controllable via wireless?

  [1]: http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html

body:
You need two spare digital pins to use the IR-library. These pins can be set to whatever you like. Pins D3 to D7 are free on the Moteino so the library will be OK to use if you connect the IR LED and receiver to two of those pins.

![enter image description here][1]

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


body:
Your Arduino do not need to be wireless to be able to control it wirelessly.
If you have a wireless network at home (which most people do), there is usally some ethernet RJ45 ports as well.
So instead you use a very cheap ENC28J60 to connect your arduino to the network. You can then access your Arduino wirelessly through your home router. As long as it is connected to your local network its should work.

As for connecting the IR sender and reciever, you need as said before, one digital pin for recieving IR-signals and one digital pin for sending. Which should be no problem even when adding the ENC28J60. It should also work very well with the Moteino if you choose to go that way.


message:
How to sense snow and ice?

We are building an outdoor snow melting system for the pavement. It would be nice if it could turn on itself only when it is needed: if there is snow, ice in the surface or the pavement is wet and the temperature is below the freezing point. Is there a good way to detect if the surface of something is snowy, icy or wet?

body:
If the pavement is black, you could detect snow by infrared reflectivity. You might detect wet by resistivity. That leaves ice. Reflectivity might work there, too, at a different threshold. You'd need to experiment.

Another possibility might be a short-range sonar. If the measured distance changes, something is there. Ice would probably read as nearer. You'd probably need to average a number of measurements to increase the measurement resolution; you care about very thin ice coatings. Snow might well read as no return - but again, experiment.

A combination of the reflectivity and sonar might be the most reliable.


body: I may experiment with a simple photocell used to turn lights on or off, and a light source for night time.  Mount the photocell so that its lens is upwards towards the sky, at night you'd need a light source shining on the photocell, I'm thinking a very low wattage led light to reduce power consumption, or even another photocell or astronomical time clock to turn the light source on or off, depending on how complex you'd want to make it.  When the photocell can no longer detect light you know it is covered.  You'd have to experiment with the opaqueness of the snow, and how much coverage would block out the light.  Seems like a cheap, easy, pretty much "out of the box" solution for snow anyway.


body:
cheap video camera with snow detection software. See [this article][1] for a start

  [1]: https://core.ac.uk/download/pdf/188092083.pdf


message:
Importance of resistor

I'm new to Arduino and also new to electronics. I'm following the tutorial [here][1]. I'm not understanding the importance of the resistor in this schematic diagram. Can someone please help me on this?

![enter image description here][2]

  [1]: http://arduino.cc/en/Tutorial/DigitalReadSerial
  [2]: https://i.stack.imgur.com/ilSHW.png

body: Without the resistor, closing the switch would connect the positive supply directly to the negative supply. This would cause the voltage across all digital components in the circuit to drop close to 0V, **crashing the whole thing**.


body:
That resistor, where positioned, is called a pull-down resistor, and if replaced by a straight wire, that circuit would short out when the switch was closed.

The purpose of this is that when a digital input pin is not connected, it floats, and if the switch were open that pin could see upwards of 2v floating value from external and internal noise. With Digital circuitry, any value in this float range can be invalid and return invalid results.

A pull down resistor will generally have a very high ohmic value >5kohm, as to allow as little current pass as possible. Here, you are shorting the pin to ground through the resistor so it will not have a LOW value when the switch is open, instead of possibly invalid.

When the switch is closed, you will have 5v passing through switch into the pin, to be read as a HIGH value, also sending 5v across a 10k or so resistor to ground, consuming only .5mA of current.

It you want to see what I mean by a floating value, debug the output of any analog pin with a wire going nowhere, and watch as the value changes. Try touching the wire, now add a pull down to ground, or try pulling it up to 5v and observe the behavior.

Happy Arduinoing!


body:
In the above circuit there are several other resistances that are being ignored for simplicity and because most of them are extremely tiny. However, one of the resistances is significant, and that it the internal resistance of the power supply.

Without the resistor shown in the schematic, the internal resistance of the battery becomes the most significant resistance in the circuit and the voltage measure at D2 would remain near zero when the switch is closed and very near zero when the switch is opened.

If the resistor shown were several thousand ohms or greater, the voltage at D2 would measure close to 5 volts when the switch is closed and zero when the switch is open (however D2 will be subject to picking up any nearby static electricity or strong electromagnetic fields when the switch is open).

To prevent D2 from being subject to spurious noise, resistors are often used between signal points and ground to dampen any such undesired noise. To better imagine how this works, imagine a 100 megohm resistor connected to D2 with the other end hanging out into the air. The unconnected end of the large resistor is acting like an antenna picking up any possible noise in the vicinity. Because the resistor shown in the diagram is so much smaller then the imaginary resistor, the noise will seem to be shorted out to ground in comparison.

In a very real sense, this schematic is telling you to add in a known resistor to ground or suffer from the effects of all the resistors not show; some being very very high resistance and some being nearly non-existent.


body:
Check out the internal pull-up resistor (disconnected by default) for Arduino as well. Save yourself wiring up an extra resistor.

    pinMode(5, INPUT_PULLUP); // Enable internal pull-up resistor on pin 5

From SparkFun: [Pull-up Resistors][1]

  [1]: https://learn.sparkfun.com/tutorials/pull-up-resistors/what-is-a-pull-up-resistor


message:
PROGMEM: do I have to copy data from flash to RAM for reading?

I have got some difficulties understanding the memory management.

Arduino documentation says, it is possible to keep constants like strings or whatever I don't want to change during runtime in program memory. I think of it as embedded somewhere in the code segment, which must be fairly possible inside a von-Neumann-architecture. I want to make use from that to make my UI menu on a LCD possible.

But I'm bewildered by those instructions to just read and print data from program memory:

    strcpy_P(buffer, (char*)pgm_read_word(&(string_table[i]))); // Necessary casts and dereferencing, just copy.
        Serial.println( buffer );

Why on earth do I have to copy the damn content to RAM before accessing it? And if this is true, what happens to all the code then? Is it also loaded to RAM before execution? How is the code (32kiB) handled then with only 2kiB RAM? Where are those little goblins carrying floppy disks?

And even more interesting: What happens to literal constants like in this expression:

    a = 5*(10+7)

are 5, 10 and 7 really copied to RAM before loading them into registers? I just can't believe that.

body:
AVR is a modified Harvard architecture family, so code is stored in flash only, whereas data exists primarily in RAM when being manipulated.

With that in mind, let's address your questions.

> Why on earth do I have to copy the damn content to RAM before accessing it?

You don't need to per se, but by default code assumes that data is in RAM unless the code is modified to specifically look in flash for it (such as with `strcpy_P()`).

> And if this is true, what happens to all the code then? Is it also loaded to RAM before execution?

Nope. Harvard architecture. See the Wikipedia page for the full details.

> How is the code (32kiB) handled then with only 2kiB RAM?

The preamble generated by the compiler copies the data that should be modifiable/modified into SRAM before running the actual program.

> Where are those little goblins carrying floppy disks?

Dunno. But if you happen to see them then there's nothing I can do to help.

> ... are 5, 10 and 7 really copied to RAM before loading them into registers?

Nah. The compiler evaluates the expression at compile time. Whatever else happens depends on the lines of code around it.


body:
This is how `Print::print` prints from program memory in the Arduino library:

    size_t Print::print(const __FlashStringHelper *ifsh)
    {
      const char PROGMEM *p = (const char PROGMEM *)ifsh;
      size_t n = 0;
      while (1) {
        unsigned char c = pgm_read_byte(p++);
        if (c == 0) break;
        n += write(c);
      }
      return n;
    }

`__FlashStringHelper*` is an empty class that allows for overloaded functions like print to differentiate a pointer to program memory from one to normal memory, as both are seen as `const char*` by the compiler (see https://stackoverflow.com/questions/16597437/arduino-f-what-does-it-actually-do)

So you could overload the `print` function for your LCD display so that it takes a `__FlashStringHelper*` argument, lets call it `LCD::print`, and then use `lcd.print(F("this is a string in progmem"));' to call it. `F()` is a macro that ensures the string is in program memory.

To predefine the string  (to be compatible with built-in Arduino print) I have used:

    const char firmware_version_s[] PROGMEM = {"1.0.2"};
    __FlashStringHelper* firmware_version = (__FlashStringHelper*) firmware_version_s;
    ...
    Serial.println(firmware_version);

I think an alternative would be something like

    size_t LCD::print_from_flash(const char *pgms)
    {
      const char PROGMEM *p = (const char PROGMEM *) pgms;
      size_t n = 0;
      while (1) {
        unsigned char c = pgm_read_byte(p++);
        if (c == 0) break;
        n += write(c);
      }
      return n;
    }

which would avoid the `__FlashStringHelper` cast.