text:
Is my Arduino dead or is it just its processor?
I have a problem with my Arduino. I can't upload any sketches to it (it gives me the error avrdude: verification error; content mismatch), but the LEDs are still blinking. Do you think that the whole Arduino is dead or is it just the chip ?
EDIT : I tried an other USB cable but it changed nothing.
EDIT : Here is the output of verbose mode while uploading :
Taille binaire du croquis : 1 084 octets (d'un max de 32 256 octets)
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/cu.usbmodem641 -b115200 -D -Uflash:w:/var/folders/56/7b6d3xm14n31kjrw8609ywjw0000gn/T/build1168987322216849272.tmp/Blink.cpp.hex:i

avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/trevorannedenise/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbmodem641
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         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  3600  3600 0xff 0xff
                                  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 0xff 0xff
                                  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  4500  4500 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  4500  4500 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  4500  4500 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  4500  4500 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 : Arduino
         Description     : Arduino
avrdude: Send: A [41] . [80]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [81]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [04]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [04]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [98]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
         Hardware Version: 3
         Firmware Version: 4.4
avrdude: Send: A [41] . [84]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [85]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [86]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [87]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [89]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: Send: A [41] . [81]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [04]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [04]
avrdude: Recv: . [10]
avrdude: Send: B [42] . [86] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00] . [80] . [04] . [00] . [00] . [00] . [80] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: E [45] . [05] . [04] . [d7] . [c2] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: P [50]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: AVR device initialized and ready to accept instructions

Reading | avrdude: Send: u [75]   [20]
avrdude: Recv: . [14] . [1e] . [95] . [0f] . [10]
################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: Send: V [56] . [a0] . [03] . [fc] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: V [56] . [a0] . [03] . [fd] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: V [56] . [a0] . [03] . [fe] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: V [56] . [a0] . [03] . [ff] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: reading input file "/var/folders/56/7b6d3xm14n31kjrw8609ywjw0000gn/T/build1168987322216849272.tmp/Blink.cpp.hex"
avrdude: writing flash (1084 bytes):

Writing | avrdude: Send: U [55] . [00] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: d [64] . [00] . [80] F [46] . [0c] . [94] a [61] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] . [9d] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [0c] . [94] ~ [7e] . [00] . [00] . [00] . [00] . [00] $ [24] . [00] ' [27] . [00] * [2a] . [00] . [00] . [00] . [00] . [00] % [25] . [00] ( [28] . [00] + [2b] . [00] . [00] . [00] . [00] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
#####avrdude: Send: U [55] @ [40] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: d [64] . [00] . [80] F [46] # [23] . [00] & [26] . [00] ) [29] . [00] . [04] . [04] . [04] . [04] . [04] . [04] . [04] . [04] . [02] . [02] . [02] . [02] . [02] . [02] . [03] . [03] . [03] . [03] . [03] . [03] . [01] . [02] . [04] . [08] . [10]   [20] @ [40] . [80] . [01] . [02] . [04] . [08] . [10]   [20] . [01] . [02] . [04] . [08] . [10]   [20] . [00] . [00] . [00] . [07] . [00] . [02] . [01] . [00] . [00] . [03] . [04] . [06] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [00] . [11] $ [24] . [1f] . [be] . [cf] . [ef] . [d8] . [e0] . [de] . [bf] . [cd] . [bf] . [11] . [e0] . [a0] . [e0] . [b1] . [e0] . [ea] . [e3] . [f4] . [e0] . [02] . [c0] . [05] . [90] . [0d] . [92] . [a2] 0 [30] . [b1] . [07] . [d9] . [f7] . [11] . [e0] . [a2] . [e0] . [b1] . [e0] . [01] . [c0] . [1d] . [92] . [ab] 0 [30] . [b1] . [07] . [e1] . [f7] . [0e] . [94] . [0c] . [02] . [0c] . [94] . [1b] . [02] . [0c] . [94] . [00] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [80] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: d [64] . [00] . [80] F [46] . [80] . [91] . [00] . [01] a [61] . [e0] . [0e] . [94] . [b8] . [01] h [68] . [ee] s [73] . [e0] . [80] . [e0] . [90] . [e0] . [0e] . [94] . [e5] . [00] . [80] . [91] . [00] . [01] ` [60] . [e0] . [0e] . [94] . [b8] . [01] h [68] . [ee] s [73] . [e0] . [80] . [e0] . [90] . [e0] . [0e] . [94] . [e5] . [00] . [08] . [95] . [80] . [91] . [00] . [01] a [61] . [e0] . [0e] . [94] y [79] . [01] . [08] . [95] . [1f] . [92] . [0f] . [92] . [0f] . [b6] . [0f] . [92] . [11] $ [24] / [2f] . [93] ? [3f] . [93] . [8f] . [93] . [9f] . [93] . [af] . [93] . [bf] . [93] . [80] . [91] . [06] . [01] . [90] . [91] . [07] . [01] . [a0] . [91] . [08] . [01] . [b0] . [91] . [09] . [01] 0 [30] . [91] . [0a] . [01] . [01] . [96] . [a1] . [1d] . [b1] . [1d] # [23] / [2f] - [2d] _ [5f] - [2d] 7 [37]   [20] . [f0] - [2d] W [57] . [01] . [96] . [a1] . [1d] . [b1] . [1d]   [20] . [93] . [0a] . [01] . [80] . [93]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [c0] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: d [64] . [00] . [80] F [46] . [06] . [01] . [90] . [93] . [07] . [01] . [a0] . [93] . [08] . [01] . [b0] . [93] . [09] . [01] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [80] . [93] . [02] . [01] . [90] . [93] . [03] . [01] . [a0] . [93] . [04] . [01] . [b0] . [93] . [05] . [01] . [bf] . [91] . [af] . [91] . [9f] . [91] . [8f] . [91] ? [3f] . [91] / [2f] . [91] . [0f] . [90] . [0f] . [be] . [0f] . [90] . [1f] . [90] . [18] . [95] . [9b] . [01] . [ac] . [01] . [7f] . [b7] . [f8] . [94] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] f [66] . [b5] . [a8] . [9b] . [05] . [c0] o [6f] ? [3f] . [19] . [f0] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [7f] . [bf] . [ba] / [2f] . [a9] / [2f] . [98] / [2f] . [88] ' [27] . [86] . [0f] . [91] . [1d]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [00] . [01]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: d [64] . [00] . [80] F [46] . [a1] . [1d] . [b1] . [1d] b [62] . [e0] . [88] . [0f] . [99] . [1f] . [aa] . [1f] . [bb] . [1f] j [6a] . [95] . [d1] . [f7] . [bc] . [01] - [2d] . [c0] . [ff] . [b7] . [f8] . [94] . [80] . [91] . [02] . [01] . [90] . [91] . [03] . [01] . [a0] . [91] . [04] . [01] . [b0] . [91] . [05] . [01] . [e6] . [b5] . [a8] . [9b] . [05] . [c0] . [ef] ? [3f] . [19] . [f0] . [01] . [96] . [a1] . [1d] . [b1] . [1d] . [ff] . [bf] . [ba] / [2f] . [a9] / [2f] . [98] / [2f] . [88] ' [27] . [8e] . [0f] . [91] . [1d] . [a1] . [1d] . [b1] . [1d] . [e2] . [e0] . [88] . [0f] . [99] . [1f] . [aa] . [1f] . [bb] . [1f] . [ea] . [95] . [d1] . [f7] . [86] . [1b] . [97] . [0b] . [88] ^ [5e] . [93] @ [40] . [c8] . [f2] ! [21] P [50] 0 [30] @ [40] @ [40] @ [40] P [50] @ [40] h [68] Q [51] | [7c] O [4f] ! [21] . [15] 1 [31] . [05] A [41] . [05] Q [51] . [05] q [71] . [f6] . [08] . [95] x [78] . [94] . [84] . [b5]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
######avrdude: Send: U [55] @ [40] . [01]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: d [64] . [00] . [80] F [46] . [82] ` [60] . [84] . [bd] . [84] . [b5] . [81] ` [60] . [84] . [bd] . [85] . [b5] . [82] ` [60] . [85] . [bd] . [85] . [b5] . [81] ` [60] . [85] . [bd] . [ee] . [e6] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [e1] . [e8] . [f0] . [e0] . [10] . [82] . [80] . [81] . [82] ` [60] . [80] . [83] . [80] . [81] . [81] ` [60] . [80] . [83] . [e0] . [e8] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [e1] . [eb] . [f0] . [e0] . [80] . [81] . [84] ` [60] . [80] . [83] . [e0] . [eb] . [f0] . [e0] . [80] . [81] . [81] ` [60] . [80] . [83] . [ea] . [e7] . [f0] . [e0] . [80] . [81] . [84] ` [60] . [80] . [83] . [80] . [81] . [82] ` [60] . [80] . [83] . [80] . [81] . [81] ` [60] . [80] . [83] . [80] . [81] . [80] h [68] . [80] . [83] . [10] . [92] . [c1] . [00] . [08] . [95] . [cf] . [93] . [df] . [93] H [48] / [2f] P [50] . [e0] . [ca] . [01] . [86] V [56] . [9f] O [4f]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [80] . [01]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: d [64] . [00] . [80] F [46] . [fc] . [01] 4 [34] . [91] J [4a] W [57] _ [5f] O [4f] . [fa] . [01] . [84] . [91] . [88] # [23] i [69] . [f1] . [90] . [e0] . [88] . [0f] . [99] . [1f] . [fc] . [01] . [e8] Y [59] . [ff] O [4f] . [a5] . [91] . [b4] . [91] . [fc] . [01] . [ee] X [58] . [ff] O [4f] . [c5] . [91] . [d4] . [91] f [66] # [23] Q [51] . [f4] / [2f] . [b7] . [f8] . [94] . [8c] . [91] . [93] / [2f] . [90] . [95] . [89] # [23] . [8c] . [93] . [88] . [81] . [89] # [23] . [0b] . [c0] b [62] 0 [30] a [61] . [f4] / [2f] . [b7] . [f8] . [94] . [8c] . [91] . [93] / [2f] . [90] . [95] . [89] # [23] . [8c] . [93] . [88] . [81] . [83] + [2b] . [88] . [83] / [2f] . [bf] . [06] . [c0] . [9f] . [b7] . [f8] . [94] . [8c] . [91] . [83] + [2b] . [8c] . [93] . [9f] . [bf] . [df] . [91] . [cf] . [91] . [08] . [95] H [48] / [2f] P [50] . [e0] . [ca] . [01] . [82] U [55] . [9f] O [4f] . [fc] . [01] $ [24] . [91] . [ca] . [01]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [c0] . [01]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: d [64] . [00] . [80] F [46] . [86] V [56] . [9f] O [4f] . [fc] . [01] . [94] . [91] J [4a] W [57] _ [5f] O [4f] . [fa] . [01] 4 [34] . [91] 3 [33] # [23] . [09] . [f4] @ [40] . [c0] " [22] # [23] Q [51] . [f1] # [23] 0 [30] q [71] . [f0] $ [24] 0 [30] ( [28] . [f4] ! [21] 0 [30] . [a1] . [f0] " [22] 0 [30] . [11] . [f5] . [14] . [c0] & [26] 0 [30] . [b1] . [f0] ' [27] 0 [30] . [c1] . [f0] $ [24] 0 [30] . [d9] . [f4] . [04] . [c0] . [80] . [91] . [80] . [00] . [8f] w [77] . [03] . [c0] . [80] . [91] . [80] . [00] . [8f] } [7d] . [80] . [93] . [80] . [00] . [10] . [c0] . [84] . [b5] . [8f] w [77] . [02] . [c0] . [84] . [b5] . [8f] } [7d] . [84] . [bd] . [09] . [c0] . [80] . [91] . [b0] . [00] . [8f] w [77] . [03] . [c0] . [80] . [91] . [b0] . [00] . [8f] } [7d] . [80] . [93] . [b0] . [00] . [e3] / [2f] . [f0] . [e0] . [ee] . [0f] . [ff] . [1f] . [ee] X [58] . [ff] O [4f] . [a5] . [91] . [b4] . [91] / [2f] . [b7]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [00] . [02]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: d [64] . [00] < [3c] F [46] . [f8] . [94] f [66] # [23] ! [21] . [f4] . [8c] . [91] . [90] . [95] . [89] # [23] . [02] . [c0] . [8c] . [91] . [89] + [2b] . [8c] . [93] / [2f] . [bf] . [08] . [95] . [cf] . [93] . [df] . [93] . [0e] . [94] > [3e] . [01] . [0e] . [94] . [97] . [00] . [c0] . [e0] . [d0] . [e0] . [0e] . [94] . [80] . [00]   [20] . [97] . [e1] . [f3] . [0e] . [94] . [00] . [00] . [f9] . [cf] . [f8] . [94] . [ff] . [cf] . [0d] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
### | 100% 0.21s

avrdude: 1084 bytes of flash written
avrdude: verifying flash memory against /var/folders/56/7b6d3xm14n31kjrw8609ywjw0000gn/T/build1168987322216849272.tmp/Blink.cpp.hex:
avrdude: load data flash data from input file /var/folders/56/7b6d3xm14n31kjrw8609ywjw0000gn/T/build1168987322216849272.tmp/Blink.cpp.hex:
avrdude: input file /var/folders/56/7b6d3xm14n31kjrw8609ywjw0000gn/T/build1168987322216849272.tmp/Blink.cpp.hex contains 1084 bytes
avrdude: reading on-chip flash data:

Reading | avrdude: Send: U [55] . [00] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: t [74] . [00] . [80] F [46]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff]
avrdude: Recv: . [10]
#####avrdude: Send: U [55] @ [40] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: t [74] . [00] . [80] F [46]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [80] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: t [74] . [00] . [80] F [46]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [c0] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: t [74] . [00] . [80] F [46]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [00] . [01]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: t [74] . [00] . [80] F [46]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff]
avrdude: Recv: . [10]
######avrdude: Send: U [55] @ [40] . [01]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: t [74] . [00] . [80] F [46]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [80] . [01]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: t [74] . [00] . [80] F [46]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [c0] . [01]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: t [74] . [00] . [80] F [46]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff]
avrdude: Recv: . [10]
######avrdude: Send: U [55] . [00] . [02]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: t [74] . [00] < [3c] F [46]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff]
avrdude: Recv: . [10]
### | 100% 0.16s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x0c != 0xff
avrdude: verification error; content mismatch
avrdude: Send: Q [51]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]

avrdude done.  Thank you.

Have you tried to reflash the bootloader? Is it blinking with your current sketch, or a previous sketch?

Any sketches? Does that mean you've tested something really simple, like blink? http://arduino.cc/en/tutorial/blink#.UxXkwF6IuWY

Yes I tried blink !

It's possible you have a non-fatal problem

check power
check connections
reflash the Arduino bootloader

If your Arduino has a socketed microcontroller you can try swapping it out with one that has the bootloader preloaded.

check the fuses as well

@zmo: checking the fuses is somewhat pointless. They're not actual fuses which can break, but PTC resistors which self-repair.

The fuses referred to control processor behaviour. They are not PTC resistors and don't self-repair. See the datasheet for the processor under the "fuses" section.

I've faced this problem several times!
If you are using arduino UNO, make sure to remove any serial connected device on the (Tx,RX) pins. Upload your sketch, then connect them back again.
It's because the arduino UNO has on serial pins which is used for uploading the code, there will be a conflict if there was a device that is connected to the serial the same time you upload the code.

I had faced similar problems and the solution that worked for me was to power the burning circuit with the Arduino onboard 5 volt. 3.3 Volt does work but at times it gives these errors especially while burning the bootloader.

This happened to me with a bare-bones Arduino. I disconnected everything and it still happens. I don't know what the cause is but you definitely will need to reflash the bootloader or replace the chip.
It isn't a connection or power issue, and it isn't related to having devices connected to pins 0/1 (although that can also cause problems, it will give a different error).


text:
Arduino Micro just blinks, won't connect to PC
Edit - Sorry it's a Micro not a Nano
I have a Micro board hooked up to an EasyDriver breakout using its 5V output to power the Micro.
Today I plugged it in and instead of booting up like normal the power LEDs on the wall plug, the easy driver, and the Arduino started flashing. The Micro became very hot, but not hot enough to burn.
After that if I plug the Micro into the USB port it just rapidly blinks the pin 13 LED. The PC does not detect the device but it does receive power.
Holding or pushing the reset button doesn't seem to help at all. I've used different USB cables, and different ports on the PC as well to no effect.
Is this something it can recover from? Why did all the LEDs blink like that?

expand on the "wont connect to pc" part please

@sachleen Oh sorry, I meant to say that the PC does not detect any new devices when it's plugged in, but it does receive power.

How did you hook up the 5V power from the breakout, to the Nano? Did you use the Vin, 5V or 3V3? If incorrectly connected, you might have damages the voltage regulator.

@Gerben It was hooked up to the VIN pin on the arduino. Also I just looked at the printed board and realized that this is a Micro not a nano. Woops.

Try looking on the device manager (if your on windows) to see if it shows up in any state. If you find it, right click the icon for the device, and try updating the drivers for it. It has worked for me.

I have had a similar problem, on a Pro Micro, and the PC, in the end, could not see it, and it would not show up in Device Manager. It was, to all intents and purposes, bricked.

It could be just a question of timing the double resetting of the Micro correctly, in order to enter bootloader mode, see Pro Micro & Fio V3 Hookup Guide - Troubleshooting and FAQ - Reset to Bootloader:

While the Micro is in Bootloader mode, you should see it appear in Device Manager like so:

While it is temporarily in this bootloader mode, you should be able to upload a new sketch.

However, this did not work for me and I ended up having to burn the bootloader again, via ISP, using either a USBasp or an Arduino Uno configured as an ISP.
After a number of attempts the apparently bricked Pro Micro showed up again in Device Manager, and became fully functional:

After that, all that was required was to install the correct Windows drivers, to get rid of the yellow warning icon.  From Pro Micro & Fio V3 Hookup Guide – Installing: Windows, obtain the zip file Arduino_Boards-Master.zip. Then selecting the Pro Micro in Windows Device Manager, right click and “Update Driver Software”, following these instructions, from the link:

Unzip that zip file, and don’t forget where you’ve left its contents.
  In that zip file, you should find an INF file, which contains all the
  information Windows needs to install the Pro Micro’s driver. This
  sparkfun.inf will be found in Arduino_Boards-master → sparkfun → avr →
  signed_driver.

Once the driver was installed, then the Pro Micro should appear correctly in Device Manager

If you haven't already done so, add the following URL to the Board Manager line in the Preferences dialog in the Arduino IDE:
https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json

Then opening the “Board Manager…” in the Tools/Boards menu, search for the “SparkFun AVR Boards” package and install it.

I have written two lengthy blogs about the whole experience:

The case of the broken Pro Micro
The case of the broken Pro Micro (reprise)

This seems a bit confused.  ATmega chips can handle 5v supply just fine; what makes a board  3.3v board is that either on an-board regulator or an off-board supply powers the chip with a lower voltage.  Run it on 5v instead and the ATmega will not be damaged, it will just be an ATmega running in spec at 5v...  Signals in excess of the supply voltage by more than a diode drop can indeed damage an ATmega (or many other parts) but that does not appear to be what the user is asking about.

I've had the same problem. I fixed it through a series of resets (removing the serial cable and plugging it in again), and punching 'make upload' a few times. Eventually it accepted my upload. The problem was an invalid code upload, which caused the Arduino to reset QUICKLY after booting. As an alternative, had this not worked, I would have blanked the chip with a USBtinyISP - it will hook up easily to your Arduino.

I had similar problem to Yours. Actually I tried to run my program in Clion IDE and then something broke in Arduino. I connected my Arduino Leonardo to my second PC clicked 2 times reset button and while the Bootloader COM appeared i fastly ran blink program.
(What is important that it wasnt one trial to run this blink program so i recommend to do it 5-10times if it doesnt work).

I have something similar happen a couple of times with some atmega328s (on arduino unos). I believe it was the bootloader that some how became corrupted and so no longer responded to the computer. The only way to fix this is to reflash the bootloader using an ISP programmer. Luckily the arduino can act as an ISP programmer so all you need is another working arduino.
See https://www.arduino.cc/en/Tutorial/ArduinoISP for how to do this on an uno. The same can be done with the micro/nano as they all use the same atmega328p chip its just a matter of wiring it up correctly.
If you cannot reflash the bootloader with this method then one of the chips is probably damaged and would need to be replaced. At this point it might be easier to replace the whole board.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Is it OK to Serial.print(message), when the USB cable is not connected to a host PC?
Often I put a bunch of Serial.print( F("debugging messages") ) in my Arduino sketch.
Normally those messages go up a USB cable to a host PC so those messages can be seen on the serial monitor.
I want to install this Arduino as part of a stand-alone system far from any PC and plug the "host" end of the USB cable into a wall-wart USB charger.
Without anything to accept those messages, the buffer on the Arduino eventually fills up, right?
Do I need to do anything to keep the Arduino from overflowing and crashing when it's not connected to a host PC?
Does it make any difference if I'm using a (1) "single-chip" Arduino-compatible where the processor includes on-chip USB, vs. (2) an Arduino-compatible with separate "USB interface chip" and "processor chip"?
(By "single-chip Arduino-compatible", I mean things like the Arduino Leonardo, Arduino Yún, LilyPad Arduino USB, Arduino Micro, the Teensy-LC, etc.)

It is OK to write out serial data with nothing connected.
In case (2) "Arduino + USB interface chip", the arduino has no idea if anything is connected or listening to the serial port. The code will transmit the bytes and act exactly the same whether plugged in to anything or not.
In case (1) "arduino with built in USB" it has some idea, but just drops bytes that are going to be transmitted when the USB port is not connected.
Hardware serial (case 2) has an output buffer, but that just makes the program a little faster. When the buffer is empty, a call to serial.{print, write} will place bytes in the buffer and move on. When it's full, Serial.{print,write} will wait until there is enough room to put the rest of the message in the buffer and move on. The hardware UART and interrupts it generates will keep taking bytes out of the buffer and transmitting them at a constant rate whether something is plugged in or not. In any case, the buffer is a fixed size and will never overflow.
As far as I can tell USB-Serial (case 1) only buffers incoming data. Since the calls to Serial.{print, write} do nothing when not connected, they may take less time than they would otherwise. If your code is really unsafe about timing, that could cause a problem, but I doubt it will.
Many examples that come with the Arduino IDE have the following bit of code that pauses native USB Arduino-compatibles until the USB connection is initialized:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

This code stops the Arduino from doing anything until the USB cable is connected.
Comment out or delete those 3 lines if you want the Arduino to run "stand-alone" without a USB cable connection (Arduino Cookbook p. 117) --
after you delete those lines, if you later plug in a USB cable, the USB will initialize correctly, and then you will see on your serial monitor everything printed by any later Serial.print() commands that run. (Tested on a Teensy LC).

When it's full, Serial.{print,write} will wait - to clarify, it fills up because of speed (ie. you are printing too fast) not because there is nothing connected.

In case (1), when you say "drops bytes that are going to be transmitted when the USB port is not connected" do you mean it transmits them (maybe into nothing) through hardware TX?

Sorry, @NickGammon, but it seems to me that, at least on a Leonardo-based board (with in-CPU USB support), if I upload a quite complex sketch with plenty of Serial.print (tested at both 9600 and 115200), I see that: 1) if I power-up the board, with external-USB connected to a PC; everything work perfectly. And still work if I "disconnect" the cable; 2) if I power-up the board WITHOUT any cable connected, the board never enter even the main loop()! - It seems to me that when buffer "fills", everything hang.
Is this an expected behaviour (...that I should circumvent at app level)?

Sketches with the Leonardo style chips with onboard USB often have a loop in setup : while (!Serial.available()) { } which loops indefinitely until the serial connection is established via the USB. It will be this loop that causes it to appear to hang. On the other boards that call returns immediately and any data sent just disappears "off the end of the wire" if nothing is plugged in. You could always make that loop exit after (say) 10,000 iterations, or after a couple of seconds have elapsed.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Coding and libraries for Maxtronix Ultrasonic sensors
I need to access distance data using a LV-EZ0 Maxtronix ultrasonic sensor: MB1000
LV-MaxSonar®-EZ0™High Performance Ultrasonic Rangefinder
Can anyone suggest what particular arduino libraries or code would be most useful?
I noticed this new ping library, NewPing
Would this work for my purposes with this particular sensor?

Likely work in pulse mode (library you mentioned) and sure work in RS232 serial mode (spec. in data sheet page 2, top, read data number as text).
How many sensors do you need and how fast update rate? Serial mode is easier if you application need small number of sensor at 'nominal' update rate (Arduino has limited number of hardware serial port, although softserial library may help).
Essentially, in pulse mode, the RX and PW pin is similar to Trig and Echo pin on many widely available sensor (several models number, basically following similar principle). Need care about the high and low relationship as may differ from the default value in library.
Taken from the data sheet of LV-MaxSonar®-EZ0

R X – If held low, the EZ0™ will stop ranging. Bring high for 20uS or
  more to command a range reading.
P W – This pin outputs a pulse width representation of range

Specifically you may want to first try the simple (old) ping: Ping Ultrasonic Range Finder
Changes needed:

Your sensor data sheet requires 20 μs trigger pulse while the above is 2 μs;
The library read a high pulse. Your sensor data sheet 'send pulse' which likely imply a HIGH pulse, may not need change;
The library use one pin for both in and out. your is one pin in (in for sensor, out for Arduino) for trigger and one put out for measurement.

Also, another library. Note the author states that many sensor from the factory differs (may need small change in code): Distance Detection
with MaxSonar ultrasonic rangefinder.


text:
Pass variable in a URL
I am working on code where I am able to manually enter the value in the URL to let the PHP code save it in the database, but I'm unsure how to do it with a variable in a loop running. This is the URL:
student.cs.hioa.no/~s180343/updatedb.php?verdi=25

Code:
void setup() {
  // Initialize Bridge
  Bridge.begin();

  // Initialize Serial
  Serial.begin(9600);

  // Wait until a Serial Monitor is connected.
  while (!Serial);
  Serial.println("Ready");

  // run various example processes

}

void loop() {
   runCurl();
   delay(10000);
}

void runCurl() {
  // Launch "curl" command and get Arduino ascii art logo from the network
  // curl is command line program for transferring data using different internet protocols
  Process p;        // Create a process and call it "p"
  p.begin("curl");  // Process that launch the "curl" command
  p.addParameter("student.cs.hioa.no/~s180343/updatedb.php?verdi=25"); // Add the URL parameter to "curl"
  p.run();      // Run the process and wait for its termination

  // A process output can be read with the stream methods
  while (p.available()>0) {
    char c = p.read();
    Serial.print(c);
  }
  // Ensure the last bit of data is sent.
  Serial.flush();
}

What do you mean by "manually entering" do you want to do subsequent curls as: verdi=25, verdi=26...?

If that's the case take a look to string appender

yes! hthwen. I want to do it in a loop so you can put a variable in verdi=$variable

Please note that duplicates (or close variants) of this question were also cross-posted to Stack Overflow and EE.SE. Cross-posting is against Stack Exchange policy, so they have been migrated/merged where possible. Some variations in question information have been lost in this process.

You can pass in a variable into a function. Something like this:
void runCurl(int verdi) {
    ...
    String myUrl = "student.cs.hioa.no/~s180343/updatedb.php?verdi=";
    myUrl += verdi;
    p.addParameter(myUrl);
    ...
}

You call the function like this, now:
runCurl(1);
runCurl(2);
runCurl(someVar);

and so on. Since it's already in your main loop() function, you just need to set pass in a different number based on whatever it is you're trying to do.

String myUrl = "student.cs.hioa.no/~s180343/updatedb.php?verdi=" + verdi;
is wrong, you can't concatenate array of char (pointer to char) to a int, you'll get erratic result.
you need to do concatenation: solution 1:
String myUrl = "student.cs.hioa.no/~s180343/updatedb.php?verdi=";
myUrl += verdi;
that mean: string(array of char) is casted to String(object) and then verdi is concatenated to the String objcet; or
String myUrl = String("student.cs.hioa.no/~s180343/updatedb.php?verdi=") + String(verdi);

@lesto you're right. I fixed it.

first of all, you declare your buffer as a string of 50 characters, but
student.cs.hioa.no/~s180343/updatedb.php?verdi=

is already 48, and you start your value at 1200 and increments over that, so basically
sprintf (buffer, "student.cs.hioa.no/~s180343/updatedb.php?verdi=%d", val)

will create a buffer of 53 characters (52 characters + \0).
Secondly, it's always a better idea to give the full URL to a program such as curl, as it might work but may give unexpected results as well if you do not provide the protocol… curl could legally assume you want ftp or gopher to access that address!
http://student.cs.hioa.no/~s180343/updatedb.php?verdi=%d

Third, here's how you setup and use your val variable:
int val=1200;
sprintf (…, "…", val);
val++;

so once you've reached 32767 your int is overflowing, getting back to -32,768.
Oh, and by the way, it is good practice on a Q&A site such as Stack Overflow to actually ask a question and say what your problem is. All my hints here are insights based on reading your flawed code.
HTH


text:
GSM and GPS shield pin conflict
I have an Arduino GSM shield and I plan to purchase an Adafruit GPS shield. The GPS module uses Pin 7 & 8 for Rx and Tx, but the GSM shield uses Pin 7 for Modem Reset.
Will the overlap on pin 7 affect it in any way? If it does cause issues, how can the problem be avoided?

This looks like a duplicate of a question you asked a few days ago (here). Are you wanting to ask something specific that wasn't covered there?

Yes, there they suggested me to go for the adafruit GPS shield. But the shied overlaps with Pin 7. I want to know, If I place this shield on the modem reset pin, how it will affect my application.

You might want to ask on the Adafruit forums.

Looking at the PDF for the Adafruit GPS shield, pin 7 is indeed hard wired to Rx and pin 8 is hard wired to Tx.

These can not be changed.
Looking at the guide for the Arduino GSM shield pin 7 is indeed reserved for modem reset:

Digital pins 2, 3 and 7 are reserved for communication between the
  Arduino and modem and cannot be used by your sketches. Communication
  between the moden and Arduino is handled by the Software Serial
  library on pins 2 and 3. Pin 7 is used for the modem reset.

As this is the case, should you stack the two shields together, without modification, then the overlap of the Rx pin on the GPS shield will cause resets to the modem on the GSM shield.
So, it seems that your best option is to use the solution provided by RedGrittyBrick, to your previous question Arduino shield stacking, the Go-Between Shield

You hear it all the time in the Arduino community, “will this shield
  work with my other shield?.” I think we’ve all been disappointed to
  find that two of our favorite shields compete for control of a digital
  pin here or a serial pin there. While there are sometimes some clever
  workarounds from elegant code modifications to aggressive
  ‘greenwiring,’ Mayhew Labs may have come up with the simplest solution
  thus far: The Go-Between Shield.

Once you have used the Go-Between shield to reassign the Rx pin to something that the GSM shield does not use, (as 2, 3 and 7 are already used, let's say you use pin 6), then in the File -> Examples -> Adafruit_GPS -> Parsing sketch, you will need to change the line
SoftwareSerial mySerial(3,2);

to
SoftwareSerial mySerial(8,6);

instead of
SoftwareSerial mySerial(8,7);

which is recommended in the PDF.
I hope that this answers your question(s). Let us know how you get on.

Addenum
The schematic of the Arduino GSM shield:

The schematic of the Adafruit GPS shield:


text:
Controlling Dynamixel MX24T, MX64T servo wirelessly using Arduino Mega?
I am planning to control multiple Dynamixel servos (MX28T or MX-64T) wirelessly using an Arduino Mega. Since this servo uses serial communication, I need an additional serial port to interface with XBee module. Although it seems to be very common application controlling these servos wirelessly based on Arduino, I could't find any of them in web. I found the two very well constructed libraries.

https://code.google.com/p/slide-33/downloads/list. This library is for MX28T servo, which is the same servo I am trying to use, but it uses UNO;therefore, I cannot interface with XBee.
The Arduino/Dynamixel Resource Page... This library uses UART1 (serial1) to interface with servo (AX-12) motors. Therefore, I can connect XBee module to UART0. But, the problem is that this library is outdated and not compatible with MX64-T servo anymore.

So my questions are:

Is there any one who has experience in controlling Dynamixel MX24T, MX64T servo series using XBee module simultaneously? If you have experience, please share with me.
Is it possible for Arduino Mega can interface with Xbee module using Serial1 (i.e., RX18 TX19)? If it can, I might be able to use the library1 without any modification.

I know, Although it is not ZigBee, ROBOTIS Arduino Shield(https://emanual.robotis.com/docs/en/parts/interface/dynamixel_shield/) can use BLE module (BT-410). My recommendation is Arduino compatible OpenCM 9.04(https://emanual.robotis.com/docs/en/parts/controller/opencm904/).
Arobotix-M(https://www.trossenrobotics.com/p/arbotix-robot-controller.aspx), you can use ZigBee.


text:
How to interface USB to custom Arduino Uno Schematic and programming atmega?
I'm fairly new to designing schematics and working with the atmega on its own and I'm designing an arduino schematic on eagle. Ive gotten to the stage where I need to incorporate a TTL USB interface in order to program the chip. I've just became aware that the arduino uses another avr chip to do so but it appears similar to the microcontroller and just need some clarification.
Since I want it all on one board like the arduino uno, my question is how is the USB-B connected to the microcontroller and how would I Incorporate it into my schematic?
Another question (out of curiosity) if I was to mass produce said PCB with one program on the atmega chip and leave out a USB module so people wouldnt be able to reprogram it (without taking the board apart obviously) How would that be done?
Heres a photo of my current schematic:

Since I want it all on one board like the arduino uno my question is how is the USB-B connected to the microcontroller and how would i Incorporate in my schematic?

The USB interface forms a bridge between the USB connector and the UART of the "master" MCU.  You don't have to use a microcontroller, but almost any UART to USB bridge chip will do the job.  Common ones are the CH340G (cheap and unstable), CP2102, FT232, etc.  The DTR signal from the USB chip is used to reset the main MCU.
You should look at the existing Uno schematics to see how the two chips are wired together.

Another question (out of curiosity) if I was to mass produce said PCB with one program on the atmega chip and leave out a USB module so people wouldnt be able to reprogram it (without taking the board apart obviously) How would that be done?

You would program the board through the ICSP pins - in the same way that you put the bootloader on.  Normally you'd invest in a proper programmer to connect up to the chip, but you can do it with an Arduino acting as the programmer.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Unable to Configure MQTT Client ID using Adafruit MQTT Library
I am utilizing the MQTT library that Adafruit has created, located here, and the library itself works wonderfully - however I am finding myself unable to edit the Client ID or configure the PINGRESP. The code that I am currently using can be seen below -
WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, "10.116.10.191", 1883);

When the client connects to the MQTT Broker the client ID turns into a random string of letters, numbers, and symbols, as seen below -
1534023607: Client ]7llG5K6J4=^tPHJHqgTUFc<Ep^m3vJ`4vSL2oB<cO[^_chw[GBp]v3smagpOqWS has exceeded timeout, disconnecting.
1534023608: New connection from 10.116.7.21 on port 1883.
1534023608: New client connected from 10.116.7.21 as ^k_aQq];7xigbIUD`htDex>IPfAoNX:4JiUkR9vY9WG[`m`GL[KqZJAk7RaEkkIu (c1, k300).
1534023608: Sending CONNACK to ^k_aQq];7xigbIUD`htDex>IPfAoNX:4JiUkR9vY9WG[`m`GL[KqZJAk7RaEkkIu (0)
1534023608: Received SUBSCRIBE from ^k_aQq];7xigbIUD`htDex>IPfAoNX:4JiUkR9vY9WG[`m`GL[KqZJAk7RaEkkIu
1534023608:     quantity (QoS 0)
1534023608: ^k_aQq];7xigbIUD`htDex>IPfAoNX:4JiUkR9vY9WG[`m`GL[KqZJAk7RaEkkIu 0 quantity
1534023608: Sending SUBACK to ^k_aQq];7xigbIUD`htDex>IPfAoNX:4JiUkR9vY9WG[`m`GL[KqZJAk7RaEkkIu

After a duration of time has passed the client exceeds the time out and disconnects.. Any advice on overcoming this obstacle would be greatly appreciated. I've tried the following for changing the ClientID, per the client constructor to the MQTT broker -
Adafruit_MQTT_Client(Client *client, const char *server, uint16_t port,
   const char *cid, const char *user, const char *pass):

WiFiClient client;
Adafruit_MQTT_Client mqtt(&client, "10.116.10.191", 1883, "Rear-Controller");

This was the result of adding the clientID, ("Rear-Controller"), after the MQTT Broker port # -
 New client connected from 10.116.7.21 as GFONMktFXFSG1rARE@JWCRv@P^XwLifdo<rCg]YFs4Ndf_>2_XIsjFsAtS08Cf\: (c1, k300, uRear-Controller)

The Client ID is expected to be stored in flash memory (it is read using pgm_read_byte). However, on the Arduino, unless told otherwise it first copies the string literal into RAM.  That means that the function is getting the address of the string in RAM, not in flash, and using it as if it were the address in flash, and that gets gibberish.
You need to force it to be in flash by creating a PROGMEM string:
const char clientid[] PROGMEM = "clientfoo";
Adafruit_MQTT_Client mqtt(&client, "10.116.10.191", 1883, clientid);

I was met with this error:
No matching function for call to 'Adafruit_MQTT_Client::Adafruit_MQTT_Client(WiFiClient*, const char [14], int, const __FlashStringHelper*)'

Not having your code to test I did wonder if that may happen. You may need to cast it to a const char * as well. Or have it separate as PROGMEM.

I converted it to a const char and it successfully compiled, however it still had the gibberish.. That only seems to effect - "(c1, k300, uRear-Controller)"

@HobarGJ See my edit. That should work.

While that did successfully compile, I am still getting the string of gibberish when connecting to the MQTT Broker. The end, "(c1, k300, uRear-Controller)", is correct and reflects the changes though. Would uploading more of my code be any easier for you?

I'd suggest switching to PubSubClient instead. It works.

@HobarGJ i agree with Majenko the MQTT-API said "If the MQTT library requires that you set a client ID then use a unique value like a random GUID.  Most MQTT libraries handle setting the client ID to a random value automatically though." i cannot see your library can require to set client ID, i also using PubSubClient, that works to me sir.


text:
List of connected clients to server
I have a server on my arduino (WiFi) and want to save the clients that connect, so that I can send to them (to each separately) data later.
Is the best data structure a linked list? How can I see if this client connected already (if there is already a connection to this ip) to avoid doubles? How can I detect when they disconnect in order to delete them?
Of course, I read the ref; but I cannot find the answers there.
Here is my minimal example (The maximum number of simultaneous connections is 5):
EDIT Keep in mind, that I just want to have a simple connection using the WiFiClient/ WiFiServer class and not a HTTP-Webserver
#include <WiFi.h>

WiFiServer server(23);
void setup() {
  server.begin();
}

void loop() {
  WiFiClient client = server.available();

  if (client) {
    //if not seen yet, add to a linked list (?)
  }
}

When you say "if this client connected already", do you mean whether there is already an active connection from the same IP address?

What is the maximum number of simultaneous connections you need to support?

@MarkSmith see edits

The WiFiClient.h header and WifiClient.cpp source files are useful for reference.

Is the best data structure a linked list?

Probably not here.  Possibly not ever.  It's a load of effort to implement, and won't give you any benefit.  Just create an array of them:
WiFiClient clients[5];

Then perhaps something like
WiFiClient newClient = server.available();
if (newClient) {
    // TODO: Check whether we have an existing connection from this IP
    // TODO: Get the first 'free' array index
    clients[firstFree] = newClient;
}

How can I see if this client connected already (if there is already a connection to this ip) to avoid doubles?

Get the remote IP address of the new client
IPAddress = newClient.remoteIP();

Do the same with all the connected clients in your array* and compare them.  If you find a match, drop the connection
newClient.disconnect();

and, probably, don't put it in the array.

How can I detect when they disconnect in order to delete them?

if (client[i].connected())

Lastly, how do we keep track of which items in our array are current active connections, and which aren't (either not yet used, or already disconnected).  You could do this several ways.  One would be to iterate through the array, checking whether the item is valid and connected:
// Returns -1 if no free slots
int firstFree() {
    for(int i=0 ; i<5 ; ++i) {
        if(!clients[i] || !clients[i].connected()) return i;
    }
    return -1;
}

All code untested so you may find typos, but I believe it's basically correct.

http is connection less. And simply putting a comment in the code is not a very good idea!

+1 Only correct answer I see here.

I have a server on my arduino (WiFi) and want to save the clients that connect, so that I can send to them (to each separately) data later.

The question (and some of the answers) seem to misunderstand how HTTP works. I know how it works (at least to an extent) as I have written server scripts in Lua, as well as C++ for the Arduino.
As I mention in my page about an Arduino HTTP server when the client initiates a request it sends an HTTP header along these lines:
POST /forum/showpost.php?id=12345&page=2 HTTP/1.1
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0)
Host: www.example.com
Cookie: foo=bar;
Accept-Language: en, mi

action=save&user_id=1234

Breaking those parts down you get this:

Once the client has sent the request it awaits (on the same connection) for the server to respond. The response may look something like this:
HTTP/1.1 200 OK
Content-Type: text/html
Connection: close
Server: HTTPserver/1.0.0 (Arduino)

<!DOCTYPE html>
<html>

<head>
<title>Arduino test</title>
</head>

<body>
<h1> My heading </h1>
<p>Some text
</body>
</html>

Notice the blank line between the HTTP header and the actual file data (the HTML data).

Under HTTP 1.1 the server can request that the connection keep open the connection by replacing:
Connection: close

by:
Connection: keep-alive

All this means is that the client is still connected and can now request other stuff (for example an image from an <img> tag). It does that by sending another HTTP header and then getting another response. It doesn't keep the connection open just so that the server can randomly send other stuff in the future.
Note: - the default under HTTP 1.1 is for the connections to be persistent.

... so that I can send to them (to each separately) data later.

You don't "send data later", that's not how it works. The client may request data later.

The standard way of keeping track of clients which are doing stuff (like filling in a series of forms) is to use cookies - that is what they are for. The server sends a cookie, the client remembers it, and sends it back with the next request. The cookie identifiers that it is the same client as before, and what it was doing. For example, a cookie might contain a token to indicate that you have logged in.

Good explanation of HTTP. Note however that the OP doesn't mention using HTTP ☺. It's perfectly valid to have a normal TCP socket connection open and for data to trickle down it as and when the server feels like it.

Good point. Still, if you have a number of connections from TCP sockets, surely you know what they are already?

I'm not sure I understand what you mean.

+1 I think you meant to say Under HTTP 1.0... since HTTP 1.1 connections are persistent by default.

Ah, OK. But you can still choose whether or not they are persistent. And judging by what I read some servers time out fairly quickly (15 seconds).

@MarkSmith - well, if you are on the phone to Aunt Ruth, you know you are talking to her, right? You don't need to write it down on a list. So if you have a number of connections open, they are in a list somewhere already, otherwise you couldn't be using them.

I still don't understand what that's got to do with anything here, but perhaps it doesn't matter :-)

@MarkSmith - the question was How can I see if this client connected already - well, if the client is connected they are in the list of connected clients. To answer the other part of the question a simple array would probably do, as you can only have about 4 connections on Ethernet shields anyway.


text:
Looping a defined function to show live variables printed on OLED screen
I have started a thread on the Arduino forum. If someone could have a look at the thread and give me some help either here or there that would be great. (I don't want to have to add all the information from that thread into this one).
https://forum.arduino.cc/index.php?topic=691659.15
The background of the code is that I am trying to call a function within the void loop() and make it loop so that it updates values on the OLED screen for temperature and humidity from a sensor. I have had this working before, but now I have a menu and cant run it straight from the void loop() as I have a menu structure.
Hi, I have been working on this project where I am monitoring and controlling humidity/temperature for a humidor I am going to build. I am using an OLED screen and right now i've been designing the menu/ UI. I know that the code right now isnt the best but I have just been trying to make it work then finalise the workings and details once its fully working. (sorry im not a big commentor in my code). I am using a rotary encoder to navigate the menu.
    if (value == 0){ //Encoder Position
Menu();
display.setTextSize(1);
display.setCursor(0,15);
display.print(">");
display.display();
  if(buttonState== LOW){ //If encoder is pressed
    value = 6;
    while (value == 6){
      MainDisplay(t,h);
    }
}

This is the problem I have, I want to call the MainDisplay() function which displays the temperature and humidity easily to read, I have tried to use a while loop while runs the function while the encoder value is equal to 6, but when I try to loop this function the OLED screen freezes and so does the serial readout in the IDE. This function calls fine when I don't try to loop it, however that isn't very useful because the screen will only display the temp & humidity from when the function is called and remains stationary.
I'm pretty new to arduino code and this is my first project, so any help or advice would be very much appreciated. Once again, I know the other parts of the code may not be the most efficient but I plan to fix this when I get the code to work and I will tidy it up.
I want this loop to run for long peroids of time because the mainDisplay() function will be on the display when not operating. I have tried changing it so when the encoder button is pressed it will exit the loop but the same thing is happening. The loop doesn't run with the code shown, the arduino just crashes and must be reset. For the other options in the menu they work fine to call the function when selected, however they aren't being looped, and they are exited when the encoder position is lowered.
Here is the full code.
#include <ClickEncoder.h>
#include <TimerOne.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DHT.h"
#define DHTPIN 12     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

#define Pa 2 //Encoder Pin A
#define Pb 3 //Encoder Pin B
#define SW A1 //Encoder Button

ClickEncoder *encoder;
int16_t last, value;
const int buttonPin = SW; //Encoder Button
int buttonState;    // variable for reading the pushbutton status
int standby = 15;
int leftnumber;

float t;
float h;
float highT;
float lowT = 50;
float highH;
float lowH = 100;

void timerIsr() {
  encoder->service();
}

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

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

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  encoder = new ClickEncoder(Pa, Pb, SW);
  Timer1.initialize(1000);
  Timer1.attachInterrupt(timerIsr);
  last = -1;
    // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT_PULLUP);

 Menu();
}

void MainDisplay(float t, float h){

  //RESET
  //delay(100);
  display.clearDisplay();

  //TEMP1
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("Temperature: ");
  display.setTextSize(2);
  display.setCursor(0,10);
  display.print(t);
  display.print(" ");
  display.setTextSize(1);
  display.cp437(true);
  display.write(167);
  display.setTextSize(2);
  display.print("C");
  //HUMIDITY1
  display.setTextSize(1);
  display.setCursor(0, 35);
  display.print("Humidity: ");
  display.setTextSize(2);
  display.setCursor(0, 45);
  display.print(h);
  display.print(" %");

  //ICON-*Flashes*
  display.fillRoundRect(100, 10, 20, 44, 2, WHITE);
  display.setCursor(105,15);
  display.setTextColor(BLACK);
  display.print("J");
  display.setCursor(105,35);
  display.print("B");
  display.display();
  //delay(20);
  //display.fillRoundRect(100, 10, 20, 44, 2, WHITE); //FLASH (copy Temp1 & Humidity1)

}
void Menu(){

    //TITLE
    display.clearDisplay();
    delay(50);
    display.setTextColor(WHITE);
    display.setTextSize(2);
    display.setCursor(40,0);
    display.print("MENU");
    //MENU1 Temp
    display.setTextSize(1);
    display.setCursor(10,25);
    display.print("Temperature Set");
    //MENU2 Humid
    display.setCursor(10,35);
    display.print("Humidity Set");
    //MENU3 Setting
    display.setCursor(10,45);
    display.print("Settings");
    //24HR Min/Max
    display.setCursor(10,55);
    display.print("Daily Min/Max");
    //RETURN
    display.setCursor(10,15);
    display.print("Main Display");

    display.setCursor(115,0);
    display.print(value);

    display.display();

}

void TempMenu(){ //Set Temperature
 value = 6;
 //ActualTEMP
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("Set Temperature =");
  display.setTextSize(1);
  display.cp437(true);
  display.write(167);
  display.setTextSize(2);
  display.print("C");
  display.display();
}
void HumMenu(){

}
void SetMenu(){

}
void MaxMenu(){ //Max/Min Temp&Hum
  value = 6;
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(2);
  display.setCursor(30,0);
  display.print("MIN/MAX");
  display.setTextSize(1);
  display.setCursor(0,25);
  display.print("Max Temperature=");
  display.print(highT);
  display.setCursor(0,35);
  display.print("Min Temperature=");
  display.print(lowT);
  display.setCursor(0,45);
  display.print("Max Humidity =");
  display.print(highH);
  display.setCursor(0,55);
  display.print("Min Humidity =");
  display.print(lowH);
  display.display();
}

void loop() {
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit
  float f = dht.readTemperature(true);

    if (t > highT){
      highT = t; //Highest Temperature
  }
    if (t < lowT){
      lowT = t; //Lowest Temperature
  }
    if (h > highH){
      highH = h; //Highest Humidity
  }
    if (h < lowH){
      lowH = h; //Lowest Humidity
  }

  value += encoder->getValue();
  if (value != last) {
    last = value;
    Serial.print("Encoder Value: ");
    Serial.println(value);
 }
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  // check if the pushbutton is pressed. If it is, the buttonState is LOW:

    if(value < 0){
      value = 0; // Doesnt allow encoder to go below 0
  }

    if (value == 0){ //Encoder Position
    Menu();
    display.setTextSize(1);
    display.setCursor(0,15);
    display.print(">");
    display.display();
      if(buttonState== LOW){ //If encoder is pressed
        value = 6;
        while (value == 6){
          MainDisplay(t,h);
        }
    }
  }

    if (value == 1){ //Encoder Position
    Menu();
    display.setTextSize(1);
    display.setCursor(0,25);
    display.print(">");
    display.display();
      if (buttonState == LOW){ //If encoder is pressed
        TempMenu();
      }
  }
    if (value == 2){ //Encoder Position
    Menu();
    display.setTextSize(1);
    display.setCursor(0,35);
    display.print(">");
    display.display();
      if (buttonState == LOW){ //If encoder is pressed
        HumMenu();
      }
  }
    if (value == 3){ //Encoder Position
    Menu();
    display.setTextSize(1);
    display.setCursor(0,45);
    display.print(">");
    display.display();
      if (buttonState == LOW){ //If encoder is pressed
        SetMenu();
      }
  }
    if (value == 4){ //Encoder Position
    Menu();
    display.setTextSize(1);
    display.setCursor(0,55);
    display.print(">");
    display.display();
          if (buttonState == LOW){ //If encoder is pressed
        MaxMenu();
      }
  }
}

I have had responses which have provided no solution. I came here to try and get some better advice as I have had better responses on stackoverflow in the past with other situations.

couple of things stand out ... the cursor movement code should be totally separate from the button press code .... all of the if (value == x) statements should be eliminated because the cursor position can be calculated display.setCursor(0,value * 10 + 15 ); .... put the button press code after the cursor code .... the button press code should run only once when the button transition happens .... it should not repeat if the button is held down .... use if (value == x) statements to choose the correct menu to display

look at the code where you update the highest/lowest ... if there is a change, then also set a flag, such as minmax_change = true; ... check if temperature and humidity have changed ... set flag temp_hum_change = true; .... further down in your code, check if the current screen should be refreshed


text:
Serial.Write(buf,Len) how to read Serial sended array of byte
hello i'm trying to send array of byte with Serial.Write(buf,Len) but don't know hot to read this code with receiver.
SENDER code:
byte buf[4]={1,2,3,4};
void setup(){
Serial.begin(250000);
}

void loop(){
Serial.write(buf,4);
}

RECEIVER code (WRONG)
byte buf[4];

void setup() {
  Serial.begin(250000); // how suggest

}

void loop() {
  int i = 0;

  if (Serial.available()) {
    Serial.readBytes(buf,4);
    Serial.print(buf[0]);
    Serial.print(buf[1]);
    Serial.print(buf[2]);
    Serial.print(buf[3]);
  }
}

How to receive this ??

if (Serial.available()) only ensures that you have at least 1 byte inside the serial buffer, not 4. Read https://hackingmajenkoblog.wordpress.com/2016/02/01/reading-serial-on-the-arduino/

You have two issues:
Firstly the transmitter is set to 250000 baud (a non-standard rate) while the receiver is set to 9600 baud. Both need to be set to the same rate.
Secondly the transmitter is constantly sending data and the receiver is constantly reading it, there is no way to ensure the two are synchronized. So your receive buffer could well end up being the end of one set of data and then the start of the next e.g. 3,4,1,2. If all you are sending is the same loop over and over this doesn't matter but for real world data it's an issue. If you have a value which you know will never be in your data (e.g. 0 or 0xff) then you can use that as a start of data marker, if not then things get a little more tricky.


text:
Wrong computation Number
im trying to make a speedometer with arduino Nano Board but when i use interrupt im getting "strange" number on variables t1 or t2 going under 0 there is the code:
volatile int impulsi =  0;
int impulsiOld = 0;
volatile int appoggio = 0;
//static int inizioDiNuovo = 0;
volatile unsigned int deltaT[3];
long t1=0;
long t2=0;

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

  pinMode(2, INPUT_PULLUP);
  attachInterrupt(0, definisciTempi, RISING);

}

void loop() {

  Serial.println(impulsi);
  if (impulsi == impulsiOld || impulsi > impulsiOld)
  {
    ;
  }
  //Serial.print("N IMPULSI: ");
  //Serial.println(impulsi);
  if (appoggio == 3) {
    appoggio = 0;
    Serial.print("DELTA T 0 : ");
    Serial.println(deltaT[0]);
    Serial.print("DELTA T 1 : ");
    Serial.println(deltaT[1]);
    Serial.print("DELTA T 2 : ");
    Serial.println(deltaT[2]);

    t1 = (deltaT[1] - deltaT[0]);
    if (t1 == 0) {
      t1 = 1;
    }
    t2 = (deltaT[2] - deltaT[1]);
    if (t2 == 0) {
      t2 = 1;
    }
    int t = t1 + t2;

    Serial.print("TEMPO T1 ");
    Serial.println(t1);
    Serial.print("TEMPO T2 ");
    Serial.println(t2);

  }

}

void definisciTempi() {
  impulsi++;
  switch(appoggio){

    case 2:
    //Serial.println("ASSEGNO DELTA T 2");
    deltaT[2] = millis();
    //Serial.println(deltaT[2]);
    appoggio = 3;
    break;

    case 1:
    //Serial.println("ASSEGNO DELTA T 1");
    deltaT[1] = millis();
    appoggio = 2;
    break;

    case 0:
    //Serial.println("ASSEGNO DELTA T 0");
    deltaT[0] = millis();
    appoggio = 1;
    break;

  }
}

how suggest i changed
unsigned int t1=0; unsigned int t2=0; into `long t1=0; long t2=0;`

output on Serial now have negative number it's for the interrupt??:
DELTA T 0 : 8785
DELTA T 1 : 8666
DELTA T 2 : 8706
TEMPO T1 40
TEMPO T2 -119  <------how 8706-8666= -119 ?

this is my pulse generator code:
const int pin = 2;
void setup() {
  pinMode(pin,OUTPUT);

}

void loop() {
 digitalWrite(pin,HIGH);
 delay(40);
 digitalWrite(pin,LOW);
 delay(40);
}

appoggio Isn't defined as volatile. All variables that get changed in the interrupt, and used in the main loop need to be volatile.

thanks i made appoggio volatile but don't change the result , every time negative number , thanks

Move "appoggio = 0;" to after al the serial.prints.

After you set appoggio = 0; and interrupt might fire, and change the variables you are currently working on.

What will happens if you get an interrupt between printing the deltas and calculating the t values? You'll end up with the t values being calculated with the new delta values (or half with the old ones, half with the new ones) . You need to disable interrupts, make a copy of the delta values and then re-enable them. You then base all your outputs and calculations on the copies.

Oddly, with the delta numbers shown: deltaT[1] - deltaT[0] == -119 and deltaT[2] - deltaT[1] == 40. In the output it appears that t1 and t2 have swapped values.

Andrew THANKS for your reply, now i just disable the interrupt for make some compute operation without problem, thanks again

The interrupt may be triggering between the Serial.print and the actual calculations, as stated by @Andrew.
Evidence supporting that fact is that your deltas are recorded in order 0, 1, 2 (ie: delta 0 < delta 1 < delta 2), However in the example output delta 0 is larger than delta 2, which suggests that a new round of delta recordings had started but not yet completed.
Updating this section as follows should fix the issue:
if (appoggio == 3) {

  noInterrupts(); // Disable interrupts while calculating

  appoggio = 0;
  Serial.print("DELTA T 0 : ");
  Serial.println(deltaT[0]);
  Serial.print("DELTA T 1 : ");
  Serial.println(deltaT[1]);
  Serial.print("DELTA T 2 : ");
  Serial.println(deltaT[2]);

  t1 = (deltaT[1] - deltaT[0]);
  if (t1 == 0) {
    t1 = 1;
  }
  t2 = (deltaT[2] - deltaT[1]);
  if (t2 == 0) {
    t2 = 1;
  }
  int t = t1 + t2;

  Serial.print("TEMPO T1 ");
  Serial.println(t1);
  Serial.print("TEMPO T2 ");
  Serial.println(t2);

  interrupts(); // re-enable interrupts

}

unsigned int t1=0;
unsigned int t2=0;

Integers on an 8 bit system can only store 16 bits of data. For unsigned that is 0 - 216-1, or 0 - 65535.
Make them unsigned long and they can store 0 - 232-1, or 0 - 4294967295.
Also, since they are unsigned, any negative value will wrap around to the maximum again. An unsigned can't store a negative value.

I'm simulating the pulse with another arduino board, how an impulse timing be negative? i have setted the time to 40ms for each pulse(sorry for my english)

now i make the change to unsigned int to unsigned long but now this the output: DELTA T 0 : 3269 DELTA T 1 : 3309 DELTA T 2 : 3349 TEMPO T1 4294967096 TEMPO T2 40

You may well be suffering from a lack of critical sections which I mentioned in your previous question.

authors: Джавид Ахундов

authors: Сергей Войков


text:
Is it possible to make an Arduino send signals to an RC receiver?
I have found bunch of information about how to hack an RC car with a PCB; and how to control an Arduino from a receiver. Also how to run a servo from an Arduino, but I'm looking for a way to make an Arduino send signals to a 27 MHz 3 channel receiver, Using three potentiometers to decide servo location.
Is there any information about this somewhere? - I have an old transmitter lying around if needed.
Links, pointers - anything is welcome.
[It does not have to be 27 MHz AM, it is just what I have on the shelve, without investing in new gear]

Ironically, your cleanest solutions might be to get a toy using an off-the-shelf 2.4 GHz chipset with a protocol that has been reverse engineered (which is to say, almost anything on 2.4 GHz that has been on the market for more than a few months) and just drive it by hanging an appropriate module for that chipset off the arduino, setting the original TX aside.

SO, what you suggest if i may "clean it up" a bit, is that i go and invest in an X-Bee shield and an RC receiever with 2.4ghz signal. If so - Is there any suggestions on how to make this work, in terms of existing arduino code?

No, I would not use an XBEE.  Take a look on rc sites and see the various 2.4 GHz chips commonly used (most are symmetric in that the same chip is used for transmitter and receiver, regardless if there is or isn't "telemetry" from the model back to the controller).  You will probably find that people already have arduino code for driving them.

The easiest way would be to open up the transmitter, desolder the potentiometer used for the stick and solder the cables to Arduino's PWM instead. Then use analogWrite() to simulate stick position. If your TX would use that potentiometer with more than 5 V, you'll not able to use full ppm values. A RC or a RCL filter may be needed between PWM output and RC input to "smooth" the PWM into an analog signal. There are a lot of online calculator to find good R, C and L to polish your signal.
This assuming your TX is using potentiometer like stick; if it is a really cheap one, it may be using buttons. If this is the case, then you connect a transistor in parallel with the button, that way you can keep manual button.
Another way is to program your Arduino to look for ppm signal (normally 50 Hz with high starting value with a period from 500 to 2000 µs) and then look for this signal into the Tx PCB; if found cut the trace of the generator and solder your cable from Arduino. I've seen around a lot of libraries outputting ppm (they are used on drones to mix single ppm channel back to PPM to use only one pin from logic board without having to hack standard RX

Please explain how one would control the transmitter with the Arduino. That's basically the whole point of this question...

Edited to be more clear. Just emulate potentiometer output with a pwm output.

This is unlikely to work without at least filtering, as both devices are varying over time - the Arduino is not outputting an analog signal but something that averages to one, and the transmitter is not measuring the potentiometer voltage continuously but rather comparing a sawtooth to it or reading it with an ADC about 50 times a second.

@ChrisStratton even if arduino pwm is by default at 200hz, problem you described may rise. Added rc and rcl filter. Also added direct injection of ppm signal

Interesting. You're assuming that the pot is wired into a voltage divider, and suggesting cutting the trace on the output of the voltage divider and feeding that trace with a filtered PWM output from the Arduino instead?

I'm assuming the pot is one of the R of the voltage divider.  especially if there is a micro after, it is the cheapest and easiest way to work with pot. but maybe this cheap tx does not use pot but button, then a transistor may be the solution

I will try this out to night when i get home. See if the pots are infact a voltage divider.

Many RC TX have a remote connector where you can input the signal and not having to open them.
In any case, 27 MHz RC are a train of pulses, of variable width, from 2 to 20 ms each, one for each channel, flowed by a 20 ms pause.
This can be recreated in a single output pin.

Such a signal may well exist internally, yes.  But 27 MHz gear tends to be the extreme low end of the market, and unlikely to expose the signal on a trainer or "buddy box" connector, so some internal probing/investigation/modification would be required.

Consider the methods of US patent 9,996,079 (linked URL):
"Radio frequency device detection and intervention": US 20180081354 A1
After reverse engineering the badly written descriptive, you should be able to come up with an Arduino board set.
P.S. Try not to copy the whole patent.


text:
How would I go about scrolling a name across a LoL shield with a potentiometer?
I am fairly new to Arduino programming and I have been set with the task of scrolling my name across a LoL shield with a potentiometer. I really don't have any idea how to do this and when I tried to look it up online there is nothing for such a task. I did look at the library references on the LoL shield website but I couldn't make sense of it.
What I did find was a LoL shield sequencer to allow animation on the LoL shield and I figured that might help but I don't know how to use that code to create a scrolling effect with a potentiometer.

What does "with a potentiometer" mean?

@IgnacioVazquez-Abrams I think it means that the text is "linked" to the string (i.e. 0% = first part of string, 50% = middle of string, etc.)

i mean the position of the text is controlled by the current position of the potentiometer. so as the potentiometer is rotated the text scrolls across the screen. if the potentiometer stops then so does the text.

You know how wide the display is. You know how wide the text is. You know the position of the potentiometer. With those you can determine where in the text (if the text is wider) or display (if the display is wider) you need to start drawing from and where you need to stop drawing. Subtracting the text width from the display width will give you the range for performing linear interpolation with the pot position.

The LoL shield library now supports exactly1 what you want.
If you choose the LoLShield_FontTest example it will scroll "HELLO WORLD!" across your shield. Change your text as required.
static const char test[]="HELLO WORLD!   ";

Example of the word "WORLD":

And in higher contrast to make it more obvious:

(1) Except for the potentiometer. In the example code where it automatically scrolls:
  for (int8_t x=DISPLAY_COLS, i=0; ; x--) {
    LedSign::Clear();
    for (int8_t x2=x, i2=i; x2<DISPLAY_COLS;) {
       int8_t w = Font::Draw (test[i2], x2, 0);
       x2 += w, i2 = (i2+1) % strlen(test);
       if (x2 <= 0)  // off the display completely?
         x = x2, i = i2;
       }
       delay(500);
    }

You would amend it to do an analogRead to set the position of x.

Example of using a potentiometer
Based on the Charliplexing example, the code below uses a pot connected to A0 to control the scroll position:
#include "Charliplexing.h"
#include "Myfont.h"

char * test = "full ASCII charset: $ % & ! [ ] { }";
int len; // length of this string

void setup()                    // run once, when the sketch starts
{
  LedSign::Init();
  len = strlen (test);
}

void loop()                     // run over and over again
{
  // start empty
  LedSign::Clear();

  int potReading = analogRead (0);  // read A0
  int i = map (potReading, 0, 1023, 0, len * 6);  // starting pixel

  for (int j = 0; j < 14; j += 6)
    Myfont::Draw(j, test[(i + j) / 6]);

  delay(100);   // hold that image for a moment

}

I would expect to see a call to analogRead() if it supported using a pot though.

True, I left that change as an exercise for the reader. I thought the scrolling text part was the hard part, making the pot choose the position would be the easy part.

Could you please explain how to use the potentiometer to control the scrolling of a word. I have used examples and I have my word scrolling across the shield but have no idea how to control it with a potentiometer. Thank you

Ignacio's answer describes the idea. You take a reading, and use that to adjust where to start displaying the text from the middle of the string you want.

I have set two values for the potentiometer one below 127 and one above 127. So if I turn the pot one way I want the word to scroll to the right and if I turn the pot the other way the word scrolls in the other direction. I do not know how to write the code to apply this reading. Any code examples or points in the right direction would help.

Please stop posting questions as "answers" - this isn't a forum. If you want to ask your own question I suggest you start a new one. Include the code you are using in it.

See amended reply.


text:
Oil Pressure / Water Pressure / Boost Pressure ( Turbo Engine )
I'm an automotive enthusiast and I want to build some gauges by myself using Arduino.
I was taking a look at this pressure transducer or sender, 100 psi, stainless steel, for oil, fuel, air, water and I was thinking if I can use this sensor to do all of the these tasks: Water, Boost and Oil Pressure.
Look at the Signal output vs read PSI chart of the sensor

I came out with this equation for the PSI calculation:
Since it is a Y = bx + a, where:
a = 0.5
b = y2 - y1 / x2 - x1 = (4.5 - 0.5 ) / (100 - 0) = 4/100 = 0.04
x = PSI
y = Signal's Voltage

This means that
Voltage Reading = 0.04PSI + 0.5
So we have :
PSI = (Voltage Reading - 0.5 ) / 0.04
Am I correct? Can I use this sensor?

You math checks you to me.
When you code it, You will probably read a voltage using an analog pin (or external ADC) that will return an integer between 0 being 0 volts, and 1024 = vin volts. vin will be 5 if you don't wire up the vin pin, and 1024 could be different if you use an external ADC.
Anyway you should be aware that the raw readings will probably not be 0-5, and they dont have decimal points. You will need to first convert the reading into the voltage with something like this:
float voltage = ((float)reading)/1024.f;

notice that the datatype float is used (enables decimal points) and that the constant being divided by is also a float so that the calculations will definitly happen between floating point numbers.

float calculation is slow on an arduino. You could just use regular integers. byte psi = (analogRead(A1)-102)/8 would be a pretty good aproximation. Or if you need more precision; int psi = (analogRead(A1)-102)*100/819.

integer arithmetic is more efficient but I doubt the time difference really matters. When I tested this there was no difference is running times between the two versions given the 4 microsecond resolution of micros().

Careful... the formula for conversion is  float voltage = ((float) rawADC  + 0.5 ) / 1024.0 * Vref (from https://www.gammon.com.au/adc with explanation). In your case 8 bit integers (0-255) are fine, no need of additional precision.

I'd add code to test for voltage between 0.0 to less than or near 0.5 volts. Disconnected pressure transducer won't present 0.5v, 0 PSI transducer voltage; not output 0.5 v @0 PSI shows a lower voltage indicated a fault or open circuit in transducer wiring. My experiences, too many times other engineers "borrowed" hardware and I wound up troubleshooting a non-fault but theft ;} Only a few lines of code to ensure connections are correct.
The floating point vs integer arithmetic compute time is outweighed by settling time of A/D converter and transducer. The auto part was my solution to show HOA board stats for my wildly varying water pressure at Condo Assn,  very cost effective too.


text:
DateTime to string
For some reason I can't use the Time.h lib.
Can you guys tell me how to create a string from the datetime into a format like this:
yyyy.MM.dd:hh.mm.ss
2014.10.29:07.12.33

Seems odd that I can't find any examples of this.

That's because they all just print it.

What DateTime are you talking about? The type from RTClib? Of some other DateTime?

Is that what you want, mate?
char buf1[20];
DateTime now = rtc.now();
//Updated now.day to now.date
sprintf(buf1, "%02d:%02d:%02d %02d/%02d/%02d",  now.hour(), now.minute(), now.second(), now.date(), now.month(), now.year());

Serial.print(F("Date/Time: "));
Serial.println(buf1);

Great answer, except that now.day() does not exist – now.date() is correct. (I tried editing but SE requires edits to be at least 6 characters…)

thanks for edit bro.

If by DateTime you are referring to RTClib's DateTime (this is something you have to clarify in your question), then you can call unixtime() method on your DateTime object. The returned value is regular Unix "epoch" time, which can be used as time_t value with functions from <time.h> (and it's <time.h>, not <Time.h>).
For example, you can use ctime to convert Unix time_t value to a C-string, although the format of that string is different from the one you requested
DateTime dt;
...
time_t t = dt.unixtime();

const char *str = ctime(&t);
Serial.println(str);

On Arduino you also have ctime_r available to you as a reentrant version of ctime.
Or, if you need more flexibility with the format, you can use gmtime or localtime and then strftime, but this might be excessive, since struct tm generated by gmtime is in essence very similar to DateTime. You can simply use snprintf in a manner suggested in @şevket Karayılan's answer.
Nevertheless, note that strftime provides you with quite extensive formatting capabilities, which would take some effort to reimplement manually
DateTime dt;
...
time_t t = dt.unixtime();
struct tm *lt = localtime(&t);

char str[32];
strftime(str, sizeof str, "%Y.%m.%d:%H.%M.%S", lt);
Serial.println(str);

strftime(str, sizeof str, "%x %X", lt);
Serial.println(str);

strftime(str, sizeof str, "%F %T", lt);
Serial.println(str);

There's no built in function to do that, I'm afraid.
I suggest you create a method that will format the string like so. Something along the lines of:
void formatTime()
{
   string str = year() + "." + month() + "." + day() + ":" + hour() + "FILL IN THE REST";
}

What is string in this case? And the initializer expression is definitely not valid.


text:
TCS3200 color sensor not reading with delay lower then 4000 ms using TimerOne.h
I'm trying to get the color sensor TCS3200 to give color values with a delay lower than 4000 ms. I've found a library to interface the TCS3200 from this link.
I've modified the code to serve my needs and its works fine, almost! The before mentioned library uses TimerOne.h, which can not accept a delay lower than 4000 ms.
My question is therefor, if it is somehow possible to modify my code, so I can lower the delay?
This is my code:
#include <TimerOne.h>

#define S0     6
#define S1     5
#define S2     4
#define S3     3
#define OUT    2

int   g_count = 0;    // count the frequecy
int   g_array[3];     // store the RGB value
int   g_flag = 0;     // filter of RGB queue
float g_SF[3];        // save the RGB Scale factor

// Init TSC230 and setting Frequency.
void TSC_Init()
{
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  pinMode(OUT, INPUT);

  digitalWrite(S0, LOW);  // OUTPUT FREQUENCY SCALING 2%
  digitalWrite(S1, HIGH);
}

// Select the filter color
void TSC_FilterColor(int Level01, int Level02)
{
  if(Level01 != 0)
    Level01 = HIGH;

  if(Level02 != 0)
    Level02 = HIGH;

  digitalWrite(S2, Level01);
  digitalWrite(S3, Level02);
}

void TSC_Count()
{
  g_count ++ ;
}

void TSC_Callback()
{
  switch(g_flag)
  {
    case 0:
         TSC_WB(LOW, LOW);              //Filter without Red
         break;
    case 1:
         g_array[0] = g_count;
         TSC_WB(HIGH, HIGH);            //Filter without Green
         break;
    case 2:
         g_array[1] = g_count;
         TSC_WB(LOW, HIGH);             //Filter without Blue
         break;
    case 3:
         g_array[2] = g_count;
         TSC_WB(HIGH, LOW);             //Clear(no filter)
         break;
   default:
         g_count = 0;
         break;
  }
}

void TSC_WB(int Level0, int Level1)      //White Balance
{
  g_count = 0;
  g_flag ++;
  TSC_FilterColor(Level0, Level1);
  Timer1.setPeriod(1000000);             // set 1s period
}

void setup()
{
  TSC_Init();
  Serial.begin(115200);
  Timer1.initialize();             // defaulte is 1s
  Timer1.attachInterrupt(TSC_Callback);
  attachInterrupt(0, TSC_Count, RISING);

  delay(4000);

  for(int i=0; i<3; i++)
    Serial.println(g_array[i]);

  g_SF[0] = 255.0/ g_array[0];     //R Scale factor
  g_SF[1] = 255.0/ g_array[1] ;    //G Scale factor
  g_SF[2] = 255.0/ g_array[2] ;    //B Scale factor

  Serial.println(g_SF[0]);
  Serial.println(g_SF[1]);
  Serial.println(g_SF[2]);
}

void loop()
{
  g_flag = 0;

    int R = int(g_array[0] * g_SF[0]);
    int G = int(g_array[1] * g_SF[1]);
    int B = int(g_array[2] * g_SF[2]);

    if((R>245) && (R<265) && (G>245) && (G<265) && (B>245) && (B<265))    // White
    {
      Serial.println("Color is white");
    }else if((R>24) && (R<44) && (G>56) && (G<76) && (B>95) && (B<115))  // Blue
    {
      Serial.println("Color is blue");
    }else if((R>56) && (R<76) && (G>107) && (G<127) && (B>80) && (B<100))  // Green
    {
      Serial.println("Color is green");
    }else if((R>171) && (R<191) && (G>154) && (G<174) && (B>71) && (B<91))  // Yellow
    {
      Serial.println("Color is yellow");
    }else if((R>77) && (R<97) && (G>46) && (G<66) && (B>43) && (B<63))  // Brown
    {
      Serial.println("Color is brown");
    }else if((R>39) && (R<59) && (G>38) && (G<58) && (B>36) && (B<56))  // Brown dark
    {
      Serial.println("Color is brown dark");
    }else if((R>20) && (R<40) && (G>43) && (G<63) && (B>48) && (B<68))  // Turkis
    {
       Serial.println("Color is turkis");
    }else if((R>39) && (R<59) && (G>77) && (G<97) && (B>55) && (B<75))  // Green
    {
       Serial.println("Color is green");
    }else
    {
      Serial.print("Red = ");
      Serial.println(R);
      Serial.print("Green = ");
      Serial.println(G);
      Serial.print("Blue = ");
      Serial.println(B);

    };

   delay(4000);
}

I've searched all over the net and didn't find any good solutions, where I can still specify the colours by hex degree.
All help would be highly appreciated!

You can increase the frequency (x10) by setting S0 HIGH and S1 LOW. Then you can change the timerone frequency from once a second to once every 100ms (Timer1.setPeriod(100000);). Then you can change your delay to delay(400). PS I think you only need to wait for a bit over 3 timerone cycles, so delay(350) should also work.

Try looking at the datasheet. No need to understand everything in there.

You can increase the frequency (x10) by setting S0 HIGH and S1 LOW. Then you can change the timerone frequency from once a second to once every 100ms (Timer1.setPeriod(100000);). Then you can change your delay to delay(400).
PS I think you only need to wait for a bit over 3 timerone cycles, so delay(350) should also work.


text:
Unstable reading from pushbutton on digital pin
I use the Pin 7 to get the status of a push button. I put 10Kohm R on the - .
The status is unstable because arduino says thet I push it but it is not true...
int button = 7;
...
// var for reading pushbutton value
int buttonState = 0;
...
buttonState = digitalRead(button);
  if(buttonState == HIGH)
  {
    myFunction();
  }

EDIT :
ARDUINO PIN 7 <---> R 10Kohm <--> [switch] <---> VCC

It sounds like you may have connected it incorrectly. Can you show a diagram of your circuit?

@Peter: thanks, I didn't use the GND like here: http://arduino.cc/en/uploads/Tutorial/button.png This looks like to be the mistake isn't it?

At the moment, your resistor isn't doing anything useful. When your switch is open, the pin is still 'floating', which means it's ending up with random stray readings from nearby electromagnetic fields.
You basically need two connections coming from your Arduino pin. One goes through a resistor straight to ground. The other goes through your switch straight to +5V.
In that case, the resistor is acting as a pull-down, because it holds your pin at Ground whenever the switch is open. You could swap over the ground and +5V, and it the resistor would function as a pull-up instead.
This question deals with the same kind of issue:

Button state changing randomly

thanks, it looks like a good asking, I'll try this in a few hours but I'm sure it will work :-)

Note that the arduino already has pull-up resistors for all the pins inside the chip. You just need to enable them. See DuncanC's answer to see how.

Note that you can also activate the internal pull-up resistor on the pin by first making it an input, then setting it to HIGH.
pinMode(pin, INPUT);
digitalWrite(pin, HIGH);

EDIT:
Based on info from Craig (in the comments below) it's simpler to use the new pinMode INPUT_PULLUP:
pinMode(pin, INPUT_PULLUP);

Then wire the switch directly to ground.
This is the simplest way to wire a pushbutton to an arduino (no resistor needed) but do you need an extra line of code.
Also, the pin will read as HIGH when not pressed, and LOW when pressed (which might seem counter-intuitive)

I'll try this method! Thanks for the tip :-)

Glad to help. Remember to up-vote if it helps, and accept the best answer. (@PeterR.Bloomfield's answer above is probably the one you should accept since it directly addresses the problem with your circuit. My answer is more of a follow-on alternate approach.)

You can now configure the internal pull-up with pinMode(pin,INPUT_PULLUP) without the need for digitalWrite.

Cool. What are the IDE/Arduino version requirements to support that?