text:
need help for exam please (deadline tomorrow)
what we're required to do on exam
You don't have to completely give me the answers, I just started learning this yesterday so I'm pressured on learning it properly + the exam, thx

We can't help you if you don't tell us at least what you have available. (Sensors, Boards, etc.).

That doesn't mention what sensor you are using for the intruder alarm. I'm sure there are several tutorials and opensource projects about this on the web. Have you searched for them?

I just asked someone and they said we didn't have to use sensors, just make sure 3 LED lights and the buzzer works together.

That doesn't make much sense. Where do you get the distance from if you don't use sensors?

I'm not sure as well, the tool for that isn't discussed at all in our handouts except now which didn't specify what we should use. I think it's the ultrasonic distance sensor since that's what I saw on my kit

I'm guessing the question is just asking you to create a conditional loop that will have the Arduino illuminate the appropriate LED when each stipulated condition is met.

You should easily find tutorials for your sensor. The ultrasonic sensor typically used in many kits is the HC-SR04. Just google for something like "HC-SR04 tutorial"

Please include the rest of the question in the question, instead of a link to a picture of the text of the question. Being specific about the actual problem(s) faced is helpful. I might consider a tutorial, or writing this exam off and starting sooner for the next one.

As written, the exam does not look like you are expected to build
something functional. Rather, that you must show that you understand how
to drive LEDs and a buzzer, how to write conditional code, etc. I would
suggest using a pot to simulate a distance reading, and writing
something along these lines:
void loop() {
    // Simulate a distance reading between 0 and 4 meters.
    float distance = analogRead(A0) * (4.0/1023);

    // React to the sensor reading.
    if (distance < 3) {
        // ...
    }
    // etc.
}


text:
SoftwareSerial error:
Please help me with this library "Softwareserial". The basic sketch does not work. Please look the errors:
    C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:128:2: error: #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors

 #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors

  ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'bool SoftwareSerial::listen()':

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:184:23: error: 'SREG' was not declared in this scope

     uint8_t oldSREG = SREG;

                       ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:185:9: error: 'cli' was not declared in this scope

     cli();

         ^

In file included from C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\cores\arduino/delay.h:27:0,

                 from C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\cores\arduino/Arduino.h:76,

                 from C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::setTX(uint8_t)':

C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\variants\arduino_zero/variant.h:62:82: error: invalid conversion from 'PortGroup*' to 'uint8_t {aka unsigned char}' [-fpermissive]

 #define digitalPinToPort(P)        ( &(PORT->Group[g_APinDescription[P].ulPort]) )

                                                                                ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:360:18: note: in expansion of macro 'digitalPinToPort'

   uint8_t port = digitalPinToPort(tx);

                  ^

C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\variants\arduino_zero/variant.h:65:44: error: base operand of '->' is not a pointer

 #define portOutputRegister(port)   ( &(port->OUT.reg) )

                                            ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:361:27: note: in expansion of macro 'portOutputRegister'

   _transmitPortRegister = portOutputRegister(port);

                           ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::setRX(uint8_t)':

C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\variants\arduino_zero/variant.h:62:82: error: invalid conversion from 'PortGroup*' to 'uint8_t {aka unsigned char}' [-fpermissive]

 #define digitalPinToPort(P)        ( &(PORT->Group[g_APinDescription[P].ulPort]) )

                                                                                ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:371:18: note: in expansion of macro 'digitalPinToPort'

   uint8_t port = digitalPinToPort(rx);

                  ^

C:\Users\Vladyslav\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.0.9\variants\arduino_zero/variant.h:66:44: error: base operand of '->' is not a pointer

 #define portInputRegister(port)    ( &(port->IN.reg) )

                                            ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:372:26: note: in expansion of macro 'portInputRegister'

   _receivePortRegister = portInputRegister(port);

                          ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:383:31: error: 'table' was not declared in this scope

   for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i)

                               ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:399:38: error: 'digitalPinToPCICR' was not declared in this scope

     if (digitalPinToPCICR(_receivePin))

                                      ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:401:78: error: 'digitalPinToPCICRbit' was not declared in this scope

       *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));

                                                                              ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:401:79: error: '_BV' was not declared in this scope

       *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));

                                                                               ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:402:37: error: 'digitalPinToPCMSK' was not declared in this scope

       *digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));

                                     ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:402:78: error: 'digitalPinToPCMSKbit' was not declared in this scope

       *digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));

                                                                              ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::end()':

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:417:36: error: 'digitalPinToPCMSK' was not declared in this scope

   if (digitalPinToPCMSK(_receivePin))

                                    ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:418:77: error: 'digitalPinToPCMSKbit' was not declared in this scope

     *digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));

                                                                             ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:418:78: error: '_BV' was not declared in this scope

     *digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));

                                                                              ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'virtual size_t SoftwareSerial::write(uint8_t)':

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:453:21: error: 'SREG' was not declared in this scope

   uint8_t oldSREG = SREG;

                     ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:454:7: error: 'cli' was not declared in this scope

   cli();  // turn off interrupts for a clean txmit

       ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:458:26: error: 'XMIT_START_ADJUSTMENT' was not declared in this scope

   tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT);

                          ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'virtual void SoftwareSerial::flush()':

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:501:21: error: 'SREG' was not declared in this scope

   uint8_t oldSREG = SREG;

                     ^

C:\Program Files (x86)\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:502:7: error: 'cli' was not declared in this scope

   cli();

       ^
PLEASE HELP ME!

Welcome. This is a Q&A system and not a dump and answer forum. Also if you provide more info and about the board used and also bother formatting the code. The answer will be as simple as you have probably tried to use the library with a board that is no compatible.

This is impossible to answer without your code, and without knowing what board you are compiling for. Please read How do I ask a good question?.

You're trying to use the AVR SoftwareSerial library with an ARM based board. It won't work. Ever.
There should be no need to use SoftwareSerial - the SAMD chips have multiple UART channels - just use one of those.

Thanks, I understand what you mean. BTW one more question. What about Bluetooth which connecting to Arduino board.
I have this line in my code:
SoftwareSerial bluetooth(1,0); In this case, i use the softwareserial library, how then to be?

source: Stack Exchange

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

sort: votes


text:
Building Multidimensional Arrays from simple arrays
Hi I am trying to write a functiont that will build a 2x4 array based on 2 1x4 arrays.
the two relevant functions are below. The first function gets information from some sensors and outputs it (I think) as a 1x4 array.
The second function is the problem and I have attached the error messages.
{
double quatCalib_mat[2][4];
double quatCalib_ABC[4];
double quatCalib_GHI[4];

 double  get_quat(Adafruit_BNO055 ref, double quatArray[])
{
  imu::Quaternion quat2 = ref.getQuat();

  quatArray[0]= quat2.w();
  quatArray[1]= quat2.x();
  quatArray[2]= quat2.y();
  quatArray[3] =quat2.z();

}

void Calibrate()
{
quatCalib_ABC=get_quat(bnoABC, quatCalib_ABC);

quatCalib_GHI=get_quat(bnoGHI, quatCalib_GHI);

quatCalib_mat= {
  {quatCalib_ABC},
  {quatCalib_GHI}
  };
}

the error messages
Arduino: 1.6.9 (Windows 7), Board: "Arduino/Genuino Uno"

E:\UNI2016\thesis\gizmo programming\Thesis_V3_M\Thesis_V3_M.ino: In function 'void Calibrate()':

Thesis_V3_M:101: error: incompatible types in assignment of 'double' to 'double [4]'

 quatCalib_ABC=get_quat(bnoABC, quatCalib_ABC);

              ^

Thesis_V3_M:103: error: incompatible types in assignment of 'double' to 'double [4]'

 quatCalib_GHI=get_quat(bnoGHI, quatCalib_GHI);

              ^

Thesis_V3_M:105: error: assigning to an array from an initializer list

 quatCalib_mat= {

              ^

exit status 1
incompatible types in assignment of 'double' to 'double [4]'

Cheers
Alex

The compiler is telling you what is wrong: The return type is not the same as the variable (double vs double[4]) in the assignment. Also there is no return statement.

As Mikael Patel said, the compiler is already hinting you about what is
wrong. But there are other issues.

In get_quat(), there is no point in returning anything, as the
function is already putting the relevant info in the quatArray
parameter.
Then, when calling get_quat(), you don't want to assign the return
value to anything.
You cannot assign an array like you did, unless it's an
initialization. I would explicitly copy the sub-arrays with
memcpy():

void get_quat(Adafruit_BNO055 ref, double quatArray[])
{
    imu::Quaternion quat2 = ref.getQuat();
    quatArray[0] = quat2.w();
    quatArray[1] = quat2.x();
    quatArray[2] = quat2.y();
    quatArray[3] = quat2.z();
}

void Calibrate()
{
    get_quat(bnoABC, quatCalib_ABC);
    get_quat(bnoGHI, quatCalib_GHI);
    memcpy(quatCalib_mat[0], quatCalib_ABC, sizeof quatCalib_ABC);
    memcpy(quatCalib_mat[1], quatCalib_GHI, sizeof quatCalib_GHI);
}

It could be noted that storing the calibration array twice (as both one
2D array and two 1D arrays) is a waste of RAM. You could get rid of the
1D arrays and have instead get_quat() fill the lines of the 2D array
directly:
void Calibrate()
{
    get_quat(bnoABC, quatCalib_mat[0]);
    get_quat(bnoGHI, quatCalib_mat[1]);
}

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


text:
MATLAB - Read from 2 SPI inputs synchronously
I am using the MATLAB Arduino Support Package to create a setup where I can read force data from a load cell and positional data from an incremental encoder - then plot them on MATLAB. It must be done at the same time in order to produce a material stress-strain curve.
I am thinking of using the SPI Device functions to do this.
Can the data from the load cell and encoder be read synchronously?

Hint: What sample frequency do you wish to achieve? Can you synchronize sampling and then read in sequence? Can you read with a higher frequency and then average to match a wanted synchronized frequency?

Yes and No.
 Synchronously in development slang means step-by-step execution. Asyncronously mean by some event.
Arduino has only one core. Even if you use interrupt, Arduino can only execute one command at once.
Best way for you I guess would be read both on Arduino and combine into single value to read at once. Just reading both with readDigitalPin  would give huge latency.

If I were to read both data inputs on Arduino and combine into a single value would there still be differences in time for those read values? Or can Arduino execute one command to both peripheral devices at the same time?

It is impossible to read both values at once with one microcontroller. Only if you combine it with external digital logic into single analog signal. But latency of reating both one by one on arduino microcontroller would be close to its frequency.

Truly parallel sampling is rarely needed.  Especially if you can separate the triggering (latching) of a reading in the peripheral from the act of subsequently transferring the latched value over SPI, it is likely you can merely trigger both in quick turn and then read them out in slightly slower turn.
But if you truly need simultaneous reading, then you will need a workaround.  The ATmega used in classic Arduinos only has one hardware SPI engine.  But you can also implement a software or "bit bang" SPI master using arbitrary digital I/O pins.
Typically this is done with single-bit GPIO operations, but if you place the critical SPI signals for both chips (probably SCLK, the others are usually only sampled at changes in that) on distinct pins of the same GPIO port, then you can use whole port operations at raw AVR level (below the Arduino API level) to drive them at effectively the same time.
To make this work, you would do the following:
1) For each SPI peripheral, figure out exactly at what transition of what part of what access sampling occurs. Make sure to include any internal setup or latency within the chip in the determination.
2) Start the access to whichever peripheral takes longer using port-wide operations which preserve the status of bits not related to this peripheral.
3) Add the access to the peripheral which takes less setup before the sampling instant by starting to include the bits connected to that in the values to be changed in the port wide GPIO operation.
4) Use a similar port-wide operation to trigger the critical sampling operation for both devices at the same time
5) Continue with whatever followup each device needs, and stop updating its pins when no more operations are needed by that device.
Do be aware that some SPI devices, particularly those which are ADC's or having ADC type behavior internally, can be quite sensitive to jitter or timing variation in the clock edges.  You may want to look at using an interrupt or even a hardware counter/time or the SPI peripheral to generate the SCLK edges, and operate the other signals with interrupt driven software slaved to that.
Again, in most cases true parallelism will not be needed.  But if it is needed methods such as this can achieve it at the cost of intricate software.


text:
Seeking help - Using CJMCU 8*8 LED matrix with arduino
The CJMCU 8*8 LED board is a grid of 64 W2812 (addressable) LEDs. The board is configured as if it was one long LED strand (just a single  DIN, 5v and GND). For some flipping hair pulling reason, my code works fine on 2812 LED strands, but I get nothing on the board. Just random flickering when I jostle the 5V wire. Any ideas? Am I completely missing something here? Pretty sure the board is fine, just can't seem to take any input...
(Here's a link to the board: http://www.aliexpress.com/store/product/CJMCU-64Bit-WS2812-5050-RGB-LED-Development-Board-Built-in-RGB-Driver-White-SKU-11481/933826_32249197598.html)

Looks a lot like https://www.adafruit.com/products/1487. Do you have more details to how you have connected it. It requires a lot of power! At least 5V 2A.

The link no longer works.

Unbelievably, as I've just discovered, this has been a known issue with these boards for at least a year and a half, yet they are still shipping them. The silk screening process of labeling the board is the problem. Just poor quality control. The front (LED) side of these low quality CMJCU-8*8 boards are incorrectly marked "SM2812B RGB LEDS". (The actual LEDs are 6 pin SM2812's, not 4 pin SM2812B's), but the real problem is with the back side of the board. The manufacturer printed the boards upside down, so that the input and output labels are reversed (DIN is really DOUT and vise versa).
I just purchased one of these defectively printed boards on line and received it a few days ago. Took me awhile to figure out why I couldn't get it to work, but I finally did. When hooked up backwards, the CMJCU-8*8 will do nothing at all (no LEDs will come on), because of the built in reverse polarity protection, but if you run your thumb hard (it's just +5V) over the other pins (the ones that include the erroneously marked DOUT) while the board is powered up, one or more of the SM2812 LEDs will magically come on. This is because your thumb makes an intermittent connection between the real DIN and the +5v rail, providing a forward bias to a few random LEDs. Once lit, these LED's will actually stay on until you cut power to the board, so if you keep ding it, you can get quite a few of the SM2812s to come on.

My CMJCU-8*8 board is labelled correctly, so try they DIN pin first.

Hi, I wouldn't have any of the leds come on if this were still the case with my board, right ?
I can only get the first two rows (or columns) to light up. They're not lighting up in a way that I would expect if the rest of the LEDS was broken (random colors, random brightnesses, no apparent logic)

I just tried it, only one LED will come on, bright blue, somewhere on the third row...

I just received 2 of these from 2 different suppliers on EBAY.
None work using the pins called [GND +5V DIN]. As it turns out the DIN is actually NOT DIN. The other connector area [GND +5V DOUT] is the DIN. Ugh!
These boards are marked CJMCU-8*8 on the back side and on the front they say "WS2812B-64 RGB LEDS". Which is another issue. They are using the 6 pin WS2812, not the 4 pin WS2812B.
So if this is what your board looks like then perhaps try the pin marked DOUT for your DIN. Or try to psych out the traces to make sure first.

Had the same issue, turned out that DOUT swapped with DIN. Thanks for a hint.

Thanks for the awesome tip about DOUT. I hooked up that one instead and now the matrix works fine. Geez.

Literally spent hours painstakingly chasing same problem. Complained bitterly to supplier that board refused to respond or operate when received. They responded by trying to tell me I had no clue about how to connect, but eventually agreed to send replacement after I proved had connected correctly, while waiting for replacement came across this post, went and found original board and reconnected, 5V to DIN side, and DIN to DOUT (Instant operation) because the reverse polarity protection does not prevent being energized this way. if supplier comes good, will have another board to compensate my trouble.

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


text:
How to extract the last byte out of an IP adress
Newbie question:
I need to pass the last byte of a local IP as a parameter.
Eg.: when Ethernet.localIP() returns 192.168.0.100,
I need to extract the 100 and put it in a char array or string.
Anyone any ideas? Thx!

localIP() returns an IPAddress object.  That object has an operator for [] allowing you to access the individual parts of it.
IPAddress ip = Ethernet.localIP();
Serial.println(ip[3]);

As simple as that :-) Thx!


text:
"Does not name a type" error with Serial.print
I am getting an error that I have never seen before and don't know how to fix. Basically I am trying to print a string (stored in thermistor) to the serial monitor. When I run the code I get an error message that says: exit status 1
'Serial' does not name a type.
What can I do fix this error?
void setup() {
Serial.begin(9600);
pinMode(4, OUTPUT);
pinMode(6, OUTPUT);
pinMode(8, OUTPUT);

}

void loop() {

} <==== ERROR: loop() ENDS TOO EARLY
String heartMonitor = codeWrite(4, HIGH, LOW, HIGH);
String lilyPad = codeWrite(6, HIGH, LOW, LOW);
String thermistor = codeWrite(8, HIGH, HIGH, LOW);
Serial.println(thermistor);
delay(1000);

String codeWrite(int pin, char output1, char output2, char output3)
{
  digitalWrite(pin, output1);
  int A = digitalRead(pin);
  delay(1);
  digitalWrite(pin, output2);
  int B = digitalRead(pin);
  delay(1);
  digitalWrite(pin, output3);
  int C = digitalRead(pin);
  delay(11);
  String code = String(A) + String(B) + String(C);
  <==== ERROR: MISSING RETURN STATEMENT
}

If you move this code into loop(), the sketch will compile.
String heartMonitor = codeWrite(4, HIGH, LOW, HIGH);
String lilyPad = codeWrite(6, HIGH, LOW, LOW);
String thermistor = codeWrite(8, HIGH, HIGH, LOW);
Serial.println(thermistor);
delay(1000);

EDIT:
The sketch should look like this:
void setup() {
  Serial.begin(9600);
  pinMode(4, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(8, OUTPUT);
}

void loop() {
  String heartMonitor = codeWrite(4, HIGH, LOW, HIGH);
  String lilyPad = codeWrite(6, HIGH, LOW, LOW);
  String thermistor = codeWrite(8, HIGH, HIGH, LOW);
  Serial.println(thermistor);
  delay(1000);
}

String codeWrite(int pin, char output1, char output2, char output3)
{
  digitalWrite(pin, output1);
  int A = digitalRead(pin);
  delay(1);
  digitalWrite(pin, output2);
  int B = digitalRead(pin);
  delay(1);
  digitalWrite(pin, output3);
  int C = digitalRead(pin);
  delay(11);
  String code = String(A) + String(B) + String(C);
}

The issue is the code can not be outside of a function.

What do you mean? That code is in void loop(). Should it be moved to a loop with a different type?

Thanks, I completely missed that my brackets were out of place.

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


text:
What does this lines mean in RFID UID Card Reader Code?
I'm currently doing a project using RFID. I'm wondering how this lines of the code work. I know that this has something to do with getting the UID of a scanned/tapped card, but can someone please explain or elaborate to me each line, how it executes? Thank you very much.
  String ID = "";
  for (byte i = 0; i < 4; i ++) {
    ID += (rfid.uid.uidByte[i] < 0x10 ? "0" : "")
          + String(rfid.uid.uidByte[i], HEX)
          + (i != 3 ? ":" : "" );
  }

which part of the code do you understand? .... which part of the code do you not understand?

I'm finding a hard time to understand the 4th and 6th lines of this specific part, so those are operators. Thank you so much for elaborating.

those are ternary operators .... the print() function would receive one of the two strings depending on a logic test result   print( 1<2 ? "this is true" : "this is not true") ....  print( 1>2 ? "this is true" : "this is not true") ..... first one would print "this is true" .... the second one would print "this is not true"

The code formats UUID as a string of 4 hex bytes (each bytes a pair of hex digits) separated by colons.
String ID = ""

Blank the string
for (byte i = 0; i < 4; i ++){

Iterate over the four bytes of the UUID
  ID +=

Add the following to the string "ID"
(rfid.uid.uidByte[i] < 0x10 ? "0" : "") +

If the hex number to be displayed is less than 0x10, add a leading '0' to the string 'ID'. This ensures the UUIDs are all aligned and all bytes within the UUID are displayed as two hex digits (even if only one is needed). It uses the ternary condition operator, which is a compact if/then/else that can only return one of two values (rather than executing chunks of code). See https://en.wikipedia.org/wiki/%3F: for more on the ternary condition operator.
 String(rfid.uid.uidByte[i], HEX) +

Add the UUID to the string 'ID' as HEX.
   (i != 3 ? ":" : "" );

Another instance of the ternary condition operator. This one adds a colon to the string 'ID' after the hex byte unless the index is 3 (ie the last one).
 }

End of for loop.
This means that the result is nn:nn:nn:nn instead of nn:nn:n:nn: (leave off trailing colon and differing numbers of hex digits).

Thank you guys for elaborating it for me. I super highly appreciate it. :)


text:
I need help programming my arduino in assembly
I am new to using an Arduino and I am trying to program my it to implement a ﬂashing pattern with two LEDs. When one LED is oﬀ, the other must be on. The program needs to be done in assembly. I have a working program in c++ but I need to convert it to assembly. I have an Arduino UNO ATmega 328p
Here is my c++ program:
 const int led = 13;
 const int led2 = 12;

 void setup() {
    pinMode(led, OUTPUT);
    pinMode(led2, OUTPUT);
 }

 void loop() {
   digitalWrite(led, HIGH);
   delay(1000);
   digitalWrite(led, LOW);
   digitalWrite(led2, HIGH);
   delay(1000);
   digitalWrite(led2, LOW);
 }

Why does it "need" to be done in assembly? School project?

And what are you looking for us to do for you? This sounds more like a call for somebody to do the work for you than a question. You'll need to research the different registers that manage the various GPIO lines, as well as the instruction set for your model of Arduino.

Did you try a web-search? Guess not :) https://www.instructables.com/id/Command-Line-Assembly-Language-Programming-for-Ard-2/ Start in Step 3 and modify. This can also be done by writing assembly in C. The Arduino core has a few functions that are written in this style, https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/wiring.c#L120

Of course I searched it, I came here as a last resort

In the case, that this is a school assignment and you actually have to program directly in assembler, you probably don't want to directly convert your C++ sketch. It will generate way more assembler code, than is really necessary for alternatively blinking two LEDs (for example digitalWrite() contains not only the actual writing to the corresponding pin registers, but much more code), and it will be obvious, that you didn't write it yourself.
In this case you have to go the harder way. You should start by looking into existing assembler blink programs. Via google I found this series at github gist, which also has a blink example. You can derive some of the program from there. Also there is a list of assembler command with descriptions.
In the end everything, that is done on a microcontroller, comes down to reading and writing Special Function Registers (SFR). The pins are organized in ports with 8 (or sometimes less) pins. Every port is then represented by one byte in the corresponding SFR (1 bit per pin). For changing the direction of a pin between output and input, the DDRX registers are used (where X is the character of the port used). For actually setting the output state (or enabling/disabling the internal pullup resistor) the PORTX registers are used. The current state (LOW or HIGH; while input or output) can be read from the PINX registers. For these things, the datasheet of the microcontroller (here the Atmega328P) is a must read (meaning: not completely, but enough to feel comfortable getting needed information from it).
Learn how to set single bits in a byte (in a SFR). You can learn it from the linked example, or from tutorials over the internet. Then write code to write the correct value to the corresponding DDRX bits to set the LED pins to output. Then you can use this to write a value to an output pin.
For blinking you need a timer. If you google for something like "arduino assembler blink" you will also find an example, which configures the timer for blinking. Basically it involves setting the Timers SFRs to the wanted values. If you don't want to do this, you might get away with executing a high number of "nop" operations (which does nothing). You would have to write a loop, that will execute a high number of times. ( very "nop" will need 1 clock cycle - credits to Ghanima for searching that up). The clock runs on 16MHz, so you can do the math to calculate, how long 1 "nop" needs, and then calculate, how many of them you need).

It's one cycle per NOP which is for the AVR architecture the most sensible thing to do.

@Ghanima Thanks, I corrected the number in my answer

There are also a couple of ways of including assembler code right inside your Arduino IDE.
By including the assembler in the Arduino IDE, the assembler source is assembled and linked into your project and uploaded to your Arduino from within the IDE - just like any other program.
This makes it easy to get started with Assembler while still retaining the familiarity of the Arduino IDE. Why? Because since you can mix C / C++ code with the Assembler code this means that you do not have to write a complete assembler program that manages all of the hardware initialisation nitty gritty - you can start small and expand your assembler as and when you you feel comfortable or need to do so. Like the example below, you can start with just two lines of assembler that fit into a larger program if you wanted to.
Following are the instructions for creating a mixed C / Assembler program in Arduino. I also give an example of how to pass parameters and get a result from an Assembler function.
To create a mixed C + Assembler program create a new project in the Arduino IDE (call it whatever you like) and enter the following code into the IDE:
extern "C" {
  void myInit();
  void myLoop();
  int myAdd(int, int);
}

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

  // This is just a dummy example showing inline assembler using the asm "directive"
  // Refer to this tutorial, or similar, for details of inline assembler in Arduino:
  // https://ucexperiment.wordpress.com/2016/03/11/arduino-inline-assembly-tutorial-5-2/
  asm(
    "ldi   r26,42"
  );
}

void loop() {
  myLoop();

  int ans = myAdd(240, 25);
  delay(ans);
  Serial.print("Answer: ");
  Serial.println(ans);
  delay(1000);
}

Next click the little down arrow in the top right corner of the IDE as per the following diagram and select "New Tab":

Enter myFunctions.S as the name of the new tab as shown below. Note that the name does not really matter, but, it must end with the extension .S and the "S" must be a capital "S" not a lowercase "s":

Paste the following code into the myFunctions.S tab.
; Example assembler file that blinks an LED.
; and adds two numbers together.

#define __SFR_OFFSET 0

#include "avr/io.h"

// Declare the three function entry points as "globals"
.global myInit
.global myLoop
.global myAdd

myInit:
  sbi   DDRB,5      ; Set PB5 (the built in LED on Arduino Uno) as output
  ret

myLoop:
  ldi   r20,250     ; Set the delay duration in ms. Maximum value is 255.
  call  myDelay_ms
  sbi   PORTB,5     ; Set PB5 HIGH
  ldi   r20,250     ; Delay for another 250 ms.
  call  myDelay_ms
  cbi   PORTB,5     ; Set PB5 LOW
  ret

; These symbols are for internal to this assembler file's use only.
; They are private because they are not listed as a global symbol
; Also, they do not conform to the subroutine calling conventions used
; by the Arduino IDE's compiler. i.e. they are not compatible with
; being called directly from C. However, since we are calling them from
; our own assembler, we can (almost) make up any calling convention we like.
myDelay_ms:
  ; Delay about r20*1ms. Destroys r20, r30, and r31.
  ; One millisecond is about 16000 cycles at 16MHz.
  ; The basic loop takes about 5 cycles, so we need about 16,000,000 / 5 = 3000 loops.
  ; NB: most instructions are 8 bit, so we load the 16 bit counter using
  ;     two 8 bit loads.
  ldi   r31, 3000>>8    ; high(3000)
  ldi   r30, 3000&255   ; low(3000)
delaylp:
  sbiw    r30, 1        ; Decrement our 1 ms counter (this instruction operates on a 16 bit value in R31:R30).
  brne    delaylp       ; If R30 is non zero, loop back
  subi    r20, 1        ; Otherwise we have passed 1 ms so, decrement the high order byte of our counter.
  brne    myDelay_ms    ; If this is non zero, loop back.
  ret                   ; Otherwise, we have counted down from R20 * 3,000 - so return.

; Function to add two integers and return an integer.
; For few parameter functions, the Arduino IDE uses registers built into the
; Microcontroller (i.e. the CPU) to exchange data between subroutine caller and callee.
; Return values are as follows:
;   - single Byte (e.g. char, byte) R24 only
;   - double Byte (e.g. int)        R25:R24 (R25 is the high order byte)
;   - quad Byte   (e.g. long)       R25:R24:R23:R22 (R25 is the high order byte)
; Parameters are passed in similar ways starting with R25 and working down, but exactly
; what is where will depend upon the parameter types.
; Refer to this tutorial for more details or the AVR compiler documentation from ATMEL
;   https://ucexperiment.wordpress.com/2016/04/02/arduino-inline-assembly-tutorial-12-functions/
; In our case, a is passed in R25:R24 and b is passed in R23:R22
myAdd:
  add     r24, r22      ; Add the low order bytes
  adc     r25, r23      ; Add the high order bytes PLUS any value carried from the previous addition.
  ret                   ; The result is in R25:R24 which is where it needs to be to pass back to the C code.

Upload it to your Uno, start the serial monitor and you should see some sum's being ouput (well one sum continuously being output). Feel free to change the values in the main loop to see different results.
I've put loads of comments and a few references into the code to get you started on the path to finding more information.
One other reference that will be useful if you are going to mess with assembler on the UNO is the ATMega-328P reference manual/datasheet (all 662 pages of it) which you can obtain from Microchip's ATmega328p reference page. There are a whole bunch more useful resources there that will likely come in handy from time to time.

It "needs" to be done in assembly as an assignment, right? Otherwise you would "want to learn" assembly.
What I suggest you do is change the C program to use port manipulation, for example:
 void setup() {
   DDRB |= 0b00100000;  // D13 to output mode
 }

 void loop() {
   PORTB |= 0b00100000;  // turn on D13
   delay(2000);
   PORTB &= ~0b00100000;  // turn off D13
   delay(2000);
 }

Now at least you are flashing D13 without using the rather complex digitalWrite and pinMode library functions. The delay is another issue I'll leave you to investigate however my page about timers might help you.
Now you can disassemble the generated code to see what the compiler generated in assembler and use that to help you learn how to do it.
For example, when I compiled the above code and turned on "verbose compiling" I found the location of the generated .elf file.
Running avr-objdump on that file (like this):
avr-objdump -S /tmp/build436d41bc5c0da39afe99cd9c05ac272a.tmp/sketch_aug13a.ino.elf > temp.txt

Gives me the following code for "loop":
00000094 <loop>:
  94:   2d 9a           sbi 0x05, 5 ; 5
  96:   60 ed           ldi r22, 0xD0   ; 208
  98:   77 e0           ldi r23, 0x07   ; 7
  9a:   80 e0           ldi r24, 0x00   ; 0
  9c:   90 e0           ldi r25, 0x00   ; 0
  9e:   0e 94 c5 00     call    0x18a   ; 0x18a <delay>
  a2:   2d 98           cbi 0x05, 5 ; 5
  a4:   60 ed           ldi r22, 0xD0   ; 208
  a6:   77 e0           ldi r23, 0x07   ; 7
  a8:   80 e0           ldi r24, 0x00   ; 0
  aa:   90 e0           ldi r25, 0x00   ; 0
  ac:   0c 94 c5 00     jmp 0x18a   ; 0x18a <delay>

What we basically see there is one "sbi" instruction to turn the LED on and one "cbi" instruction to turn it off.
As for the rest, well I don't want to do your homework for you. Have fun learning how to program in assembler!

Try this method to convert your sketch
https://sourceforge.net/projects/arduino-to-assembly-converter/

I tried that but when I run it there are multiple errors

Also you should check out chrisl's comments about being "way to much generated code" and "obvious you did not do it yourself". Unless you are aiming for an F on your project, automated conversion of the C code is not the answer. Of course it is entirely your choice as to what grade you wish to work for.


text:
Hx711 is outputting only zero
I am strain guages in a wheatstone bridge along with hx711 . For testing amplifier I used potentiometers to change the input voltage for hx711. It is outputting only zero. Here is my code.
#include "HX711.h"

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;

HX711 scale;

float calibration_factor = 282650.0;

void setup() {
  Serial.begin(57600);
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale();
  scale.tare(); //Reset the scale to 0
}

void loop() {
  if (scale.is_ready()) {
    long reading = scale.read();
    Serial.print("HX711 reading: ");
    //Serial.println(reading);
    Serial.println(scale.get_units(), 5);
  } else {
    Serial.println("HX711 not found.");
  }
  delay(1000);
}

calibration_factor is defined but not used?

I did add a line  scale.set_scale(calibration_factor);  in the void loop. But still it is giving zero. Thank you

You are welcome.


text:
Simple Arduino Serial Arithmetic
I'm developing a program to calculate static margin of an aircraft through the calculations of mass,moment and arm. Essentially dealing with large numbers.
I'm having difficulty in setting up my code in the way so that the arithmetic is applied correctly to larger numbers. What I have so far works but only when the input is 0-9. The arithmetic fails to calculate digits beyond.
I understand that I'm breaking the digits into separate variables as to convert them from ASCII format to their intended value. The problem is in putting those digits back together.
I know this is probably very simple but I'm picking up arduino again after a long break and I'm very rusty.
Here's my code thus far:
long batterymoment,num1,num2,answer;
int batterymass = 720;
int batteryposition;
boolean mySwitch = false;

void setup() {
  Serial.begin(9600);
  num1=0;
  num2=0;
  Serial.println("Enter battery position");
}

void loop() {
  while (Serial.available()){
   batteryposition = Serial.read();

   if(batteryposition>47 && batteryposition<58){
     if(!mySwitch){
       num1=(num1*10)+(batteryposition-48);
     }else{
       num2=(num2*10)+(batteryposition-48);
     }
   }

   answer=num1+num2;
   batterymoment=answer*batterymass;
   Serial.print("Battery moment is: ");
   Serial.println(batterymoment);
   num1=0;
   num1=0;
   mySwitch=false;
  }
}

Thanks.

Read and understand this before you go any further: https://hackingmajenkoblog.wordpress.com/2016/02/01/reading-serial-on-the-arduino/

will do @Majenko

Do you mean to repeat num1=0; in loop()?
It is only reading one character per loop() because loop() happens much faster than Serial.available() and Serial.read().
Do the reporting and clearing when you receive some sort of separator/non-digit character.

so you mean have a statement that requires a non-digit character to be satisfied before 'answer=num1+num2'?

Yes.  You should be able to add an else { ... } around the last chunk of code to make this work.  It would probably be cleaner to copy the characters into a buffer and then do atol(), atoi(), atof()... etc.  on the buffer after you know you have the whole message.


text:
Program around this while loop not working as expected
int i=0;
while(i == 0){
  if(digitalRead(saveSwitch) == HIGH){
    Serial.print("New coordinates saved \n");
    lat1 = gps.location.lat();
    Serial.print("Latitude");
    Serial.println(lat1);

    lng1 = gps.location.lng();
    Serial.print("Longitude");
    Serial.println(lng1);
    i = 1;
  }
}

Why isn't leaving the while loop?

Is it ever triggering the if() and printing?  If it is, what's outside this code? and does it dump it right back into the while(){}?   Maybe put a Serial.println() after the while(){} to prove you aren't misdiagnosing the unseen code.

I've printed the value of i and it's 1 after my switch goes high. I even used i++; to see if it increases, but it only increases once and after that it just prints out the lat and lng every time the switch goes high. Edit: nothing outside the while loop gets executed after i is set to 1.

Then it is getting out of the while loop.  Your problem is in the unseen, surrounding code.

All right, I'll look into the whole code and tell you what I find by tomorrow.

If you want i to maintain its state outside of the posted code, perhaps you should move the i=0; statement outside of its current scope.

Is that code from the loop() function? How many lines is the whole function? Can you add them all if it's beyond 100 lines?

Why isn't leaving the while loop?

There's a good chance that the code is  leaving the while loop, repeatedly.  However, if the code that's shown is in (eg) the loop() function, i will be reset to 0 each time the function runs, which will cause the while loop to start again.
As noted in Dave X's comment, you can move int i=0; to a higher scope. Moving it to file scope, for example, will allow it to retain its value through repeated function calls.  For example, if the code shown is in loop(), you could put int i=0; just before void loop() {.
Note, having generically-named variables like i declared at a high level is a bad idea, a blunder, a programming faux pas.  An alternative is to leave its declaration within loop() but add the static keyword so that i is allocated only once, rather than being reallocated and reinitialized at each execution of loop().  For example:  static int i=0;.

Instead of setting i=1, you could use a 'break' command to break out of the while loop.  That way you don't need 'i' at all, you can just do 'while(true)'


text:
Possibly fried a new atmega328p?
I have a new atmega328p IC that I wanted to program. To do so I placed it into the socket of an arduino uno. I accidentally placed it the wrong way around (180° rotated), and powered it via USB and tried to upload the blink sketch, which obviously did not succeed. After I noticed it I turned it around and placed it into the socket the right way. I tried again uploading the blink sketch again without success.

Have I fried the atmega328p by placing it in the socket the wrong way?
Is there something else you need to do to new atmeag328p before you can program them the usual way?

Update: It seems that just rotating the IC did not damage it in the state where there was no bootloader programmed. And and the bootloader needed to be programmed first before the IC could be used.

does the new atmega328p have a bootloader programmed?

@jsotola I don't know, I have no experience with that. Is that something you usually have to do with new ones?

if the atmega328p is blank, then you could use the Uno as a programmer .... use google to find a tutorial

@jsotola So is that something that you usually have to do with new atmega328p?

Chips come blank. It's up to you to put the bootloader on them.

Whether your chip is fried or not, we can't say, but they're reasonably tough and will stand a bit of abuse before they fail. Did anything smoke or get hot?
You can buy atmega328p chips pre-programmed with a bootloader from a few vendors, but they don't come from the factory that way so most are not. Preprogrammed chips typically cost a couple of $ US more than blank chips for the time spent by the vendor to buy blank ones, program, and repackage them for sale in small quantities, and are almost always advertised as such. If you don't know whether yours is programmed with a bootloader, it probably isn't. It's worth trying to do it yourself, on a breadboard, using a known-working Uno as a bootloader- programmer. There are lots of how-to articles on the internet.

Thanks for the explanation! It seems that mine did not have a bootloader, and I managed to program it. The basic blink program works so these are two very good signs so far! But I have yet to test all the other pins.

After a reset it should blink pin13 led as all Arduinos do. If not, I'd first try uploading  a bootloader cause I have gotten ones that don't have bootloaders. The 328p if a pretty resistant chip. One time i put 12v into a digital pin and it got so hot the smd desoldered itself but worked fine apart from that pin being blown.

Thanks, that is very good to know. It seems so far that it did survive my mistake as I managed to program the bootloader!


text:
Load Arduino flash code from SD card
I have an Arduino Uno. It doesn't have a lot of memory space, which is a bit of a nuisance. I was wondering:  Is it possible to load a text file from an SD card and compile it on the Arduino into code that the Arduino can use. I don't really care if it is slow or uses 99% of the memory space just to load on the code. If it is possible would this work: use bootup code to load a piece of code to Arduino, dispose of bootup code so there is more code, do what ever that code does, dispose of that code, load new code.

Short answer is no - you cannot change the falsh memory like you propse, but you can optimise code etc.this has already been answered here: http://arduino.stackexchange.com/questions/221/what-can-i-do-if-i-run-out-of-flash-memory-or-sram

What kind of application are you looking at? You can free up the bootloader section by using an ISP programmer instead but my guess is that the extra program memory will not help much. Could you describe your actual goal instead of a sub-problem solution.

See topic #16812, “Load sketch code from SD Card”, in forum.arduino.cc, which explains how to replace the ordinary Arduino bootloader with one that can load programs from an SD card.
Also see Bootdrive loads Arduino sketches from SD card at dangerousprototypes.com, which gives different code to do the same thing.  It also mentions BootDrive for Arduino from baldwisdom.com.
Note, the program code that these loaders install into flash is already compiled, as opposed to being original C source code.  If you want to load source-level code into the Arduino, look for an interpreter / interpretive language to run on the Arduino.

The flash memory is only designed to be reloaded 10,000 times. While that might seem a lot, if you are planning a system where, every day you load some part of code into flash, and then some other part, etc. you will use up those 10,000 writes fairly quickly.

I don't really care if it is slow or uses 99% of the memory space just to load on the code.

Well, you will care because if 99% of the memory space is the loader, you will only have 1% for the code, which defeats the purpose.

It doesn't have a lot of memory space, which is a bit of a nuisance.

I suggest a larger processor such as the Atmega1284 (128k of flash), Atmega2560 (256k of flash) or the Atmega644P (64k of flash).
All but the Atmega2560 come in DIP versions of the chips, if that helps.


text:
Working with Seed BLE Shield and Adafruit Feather BLE
Long story short: I need to pair these devices:

Arduino UNO with Seeed BLE Shield
Adafruit Feather 32u4 Bluefruit LE.

The Seeed shield is configured and able to connect and communicate via the UART to an Android phone by HM BLE Terminal app from Google Play Store.
I can also connect the phone and Feather. The two independent connections work really well but a problem occurs when connecting the Seeed shield with Feather. Connection isn't troubling No errors are reported but I can't send/receive any data via the serial monitor (I'm using bleuart_cmdmode or bleuart_datamode from the Adafruit examples).
Basically my question is how to make them work: HM-11 module with BLE and the Adafruit board (nRF51822 chipset from Nordic).

Although the nRF51822 supports Central (master) mode, the Adafruit Feather's firmware only support's Peripheral (slave) mode.

The Bluefruit LE firmware from Adafruit is currently peripheral only,
  and doesn't run in Central mode, which would cause the module to
  behave similar to your mobile phone or BLE enabled laptop.
At some point we might consider a new firmware image offering this,
  but since 98% of the uses cases for BLE involved running as a
  peripheral we've concentrated all of our development effort there for
  now.
https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/faq#faq-2

The HM-11 on your Seeed shield is capable of Central (master) mode though. This means your Uno will play the part that your Android phone was playing when you connected the Feather to the terminal app.
To set your HM-11 to Central mode, run the following AT command.
AT+ROLE1

Example code for the HM-11

Alternatively, you could burn the S120 Soft Device and your own custom firmware onto the Feather's nRF51822. You can find all the docs, tools, and Soft Device images on Nordic's website.


text:
Arduino not working / not uploading
Could anybody please help me with my problem? My Arduino doesn't work correctly. I was between a project, and suddenly it started acting weird. First, it started taking about 4 minutes to compile and a minute to upload, I do not know why!
Second, now it doesn't accept any code at all. I will paste the error message below.
Also, could anything be damaged as I inserted the USB cable of the Arduino to my power bank, rated 5V 2A, for about 30 seconds as power source and then again inserted it to the computer itself.
Please help me. I have already tried searching on various forums, reinstalling the software and driver on my PC, pressing the reset button... No help so far.

ERROR MESSAGE:
  Arduino: 1.6.7 (Windows 10), Board: "Arduino/Genuino Uno"
avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
           Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
           Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port                    : COM6
Using Programmer              : arduino
Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x49
Error opening serial port 'COM6'. (Port busy)
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x49
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x49

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

Also see Have I bricked my Arduino Uno? Problems with uploading to board

Connecting to the 5v/2A power supply would cause no trouble at all. Taking 4 minutes to compile is strange but unlikely to be related to the Arduino board. "programmer is not responding" errors are communication errors.

Did the program compile without errors?
Are any LEDs lit or blinking on your board?
Is the correct board selected in the Tools | Boards menu?
Is the correct port selected in the Tools | Ports menu?
Is the correct programmer selected in the Tools | Programmer menu?
Try another USB cable.
Try pressing/releasing the board's reset button right after you click the upload button.

Don't forget the programmer option!

yes it compiled without errors
yes LED on the board blink like normal
yes correct board is selected
yes correct port is selected
programmer im nt sure.... wat exctly shud it be?
another usb cable, ok il try that soon as i get my hands on another cable,
i tried the reset button thingy...dint work  :(

I am getting the same exact errors.  Tried different boards, cables, upgrade to 1.6.7, etc.  Maybe will go back to pre1.6 and try.  Will also try via tinyisp when I get a chance.  FYI - having no issues with studio 6/tinyusb/avrdude combination, just on arduino.  Wonder if it is a USB driver or arduino version of avrdude problem?

Confirmed - no problems uploading via usbtinyisp. Must evolve around Arduino USB?

Another confirmation - not only does usbtinyisp work good but I can also read the serial port in Putty.  Definitely something going on in Arduioland!


text:
Arduino Nano Atmega328P doesn't work on Macbook
I've bought and Arduino Nano compatible on eBay:

But by the time I connect it to my Macbook Pro (OS X El Capitan 10.11.2) doesn't appear under "Tools -> Port" in Arduino IDE:

I've followed some instructions by other posts here in StackOverflow:

Arduino Nano no serial port for MacBook Air 2013
Arduino Nano with Mac OS Yosemite 10.10

But none of them worked :(
If someone could help me out with this issue I'll be grateful.
Thanks.

What serial chip is on that board?

The chip is an Atmega 328P

No, I said SERIAL chip. Turn it over. That one, right there.

So sorry Majenko. CH340G is in the serial chip. Thanks.

Ah, I guessed as much. Good luck with that then - that chip has real problems with Yosemite.

Sorry I can't help with it since I don't use a Mac. I just know there are often problems with Yosemite.

Actually you really helped me. Because of your question about the "serial chip" I was be able to look for a solution for that chip in Yosemite! thanks :)

I was be able to solve the issue.
By looking for the serial chip my board has: CH340G I found this blog post:
http://kiguino.moos.io/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html
So I downloaded the signed driver for my chip and now it works :D
Driver: http://kiguino.moos.io/downloads/CH34x_Install.zip


text:
How can I attach I2C sensors on the small board of Intel Edison?
Sensors like Skin conductance, Body temperature and Heart Rate. Please imagine to talk to a child and keep the answer very simple so I can understand you and you don't lose time to write explanations for your answer.

Something like https://www.sparkfun.com/products/13034 would be helpful, in connecting. You need at least something to convert the 70-pin Hirose Header into a more usable connection type.

I didn't get "You need at least something to convert the 70-pin Hirose Header into a more usable connection type."

The only way to connect anything to the edison is via the 70 pin connector. Unless you're very skilled in soldering, connecting something to these pins with 0.4mm (15mil) spacing is impossible.

Surely I'm not skilled. It is the only solution you see?

If you're using the mini-breakout board (https://www.sparkfun.com/products/13025), then you can get the I2C connections from the board (connections available through holes under the Edison; you can see them from the backside; see: https://cdn.sparkfun.com//assets/parts/1/0/0/1/1/13025-02.jpg). You can solder headers on or can solder wires directly to the required pins. You can find the pin mapping here: http://iotdk.intel.com/docs/master/mraa/edison.html

Use the I2C breakout board. This will also handle voltage shift from 1.8 V to the sensor voltage level.


text:
Why does pulse sensor shows gaps when I move it?
I modified the serial code in this way and I don't think the gap is produced by my edit even because it made it even before:
//////////
/////////  All Serial Handling Code,
/////////  It's Changeable with the 'serialVisual' variable
/////////  Set it to 'true' or 'false' when it's declared at start of code.
/////////

void serialOutput(){   // Decide How To Output Serial.
 if (serialVisual == true){
     arduinoSerialMonitorVisual('-', Signal);   // goes to function that makes Serial Monitor Visualizer
 } else{
      sendDataToSerial('S', Signal);     // goes to sendDataToSerial function
 }
}

//  Decides How To OutPut BPM and IBI Data
void serialOutputWhenBeatHappens(){
 if (serialVisual == true){            //  Code to Make the Serial Monitor Visualizer Work
    //ASCII Art Madness
    Serial.print(BPM);
    Serial.println("");

 } else{
        sendDataToSerial('B',BPM);   // send heart rate with a 'B' prefix
        sendDataToSerial('Q',IBI);   // send time between beats with a 'Q' prefix
 }
}

//  Sends Data to Pulse Sensor Processing App, Native Mac App, or Third-party Serial Readers.
void sendDataToSerial(char symbol, int data ){
    Serial.print(symbol);

    Serial.println(data);
  }

//  Code to Make the Serial Monitor Visualizer Work
void arduinoSerialMonitorVisual(char symbol, int data ){
  const int sensorMin = 0;      // sensor minimum, discovered through experiment
const int sensorMax = 1024;    // sensor maximum, discovered through experiment

  int sensorReading = data;
  // map the sensor range to a range of 12 options:
  int range = map(sensorReading, sensorMin, sensorMax, 0, 11);

  // do something different depending on the
  // range value:
  switch (range) {
  case 0:
    Serial.println("");

  }
}

63

63
63
63
63
62
62
62
62
62
62
62
63
62
63
64
63
63
64
64
65
65

65
68
74
78
86
95
105
112
123
141
167
154
136
128
123
125
123
127
132
104
93
92
92
89
83
77
73
69
65
70
70
71

You can find all the code here:
https://github.com/WorldFamousElectronics/PulseSensor_Amped_Arduino
In the code I posted there is some code I don'f find useful but I can't delete it for reason linked to variables used for other functions I don't know I'm using.
You can also see huge changes in the heart rate that surely don't reflect the reality.

probably because of the badly formatted switch() case: statement. Have a look at what the Serial.println('"");

that's where I deleted things

ok I deleted the code there and now no problem. Any idea on how to fix the erroneous heart rates?

That might be something with the sensor and how it is connected, loose connections possibly.

do you mean that it's probably not enough tight on my finger?

I was talking about the electrical wiring side of loose connections, but also I am sure not having an good attachment to the finger might give bad readings, if its loose try making it tight but not to the point of loosing a finger :)

probably also the wires to the arduino weren't so fitted.

if the wires are loose the Analog reading will be very noisy

noisy in this case means that I will get the values I had?

Try using another serial terminal program (such as br@y terminal, Hterm, YAT etc.). In these programs you can control the timeout and also view line breaks.

One of the possibilities is when you move your finger, the sensor grip loosened and doesn't count a "beat". So the sensor emits data = 0, and it will cause
Serial.println("");

in your switch-case.

Upvote because this seems most likely.  If changing code doesn't matter, and the wiring is intact, then it must be the movement that is causing it.  Like the old joke:  "Doctor, it hurts when I lift my arm" and the Doctor says, "Then don't lift your arm"


text:
Hibernate Arduino for 12hrs with rtc1302 module
ok, Good morning, guys, with a data acquisition project, in this, I get data every 12 hours, even if it's only 12 hours, the arduino gets connected directly, and it's being powered by a 9v battery, for longer life of this battery, to try to hibernate the arduino with real time, using the real time clock 1302, you could help me to make a code for this clock, for I have never used it before! thank you

Arduino SE is only in English. Would you understand an answer in English?

Yes, I understand perfectly.

the translate the question to English with Google translate

ok,
Good morning, guys, with a data acquisition project, in this, I get data every 12 hours, even if it's only 12 hours, the arduino gets connected directly, and it's being powered by a 9v battery, for longer life of this battery, to try to hibernate the arduino with real time, using the real time clock 1302, you could help me to make a code for this crock, for I have never used it before! thank you

When you have never used the ds1302, then keep it that way. Don't use it. The ds3231 is a lot better. Which arduino board do you use? For the ds1302, you can start here: https://playground.arduino.cc/Main/DS1302RTC Setting the arduino uno in sleep mode might not help, there are other components that use current. For sleep mode, you can start here: https://www.gammon.com.au/power

I have a sleep_pwr_down ready, I was just thinking of adding a few lines of code to configure the ds1302 time, and to do a conditional, to wake up when it's 20 hours and sleep when it's 8 hours, without much complication, it's possible to do that way?

That is possible. You can even wake up every minute to check the time. Being active for 1% of the time requires little power. If you want to power an arduino uno with a 9v battery, then the sleep mode for the atmega chip has little effect. Did you take a good look at https://www.gammon.com.au/power ? everything you need to know is there. Which arduino board do you use.

For really low-power consider using a MOS transistor, skip the "sleep-mode" handling and power off the Arduino "completely". https://sites.google.com/site/wayneholder/low-power-techniques-for-arduino

Hello, sorry for missing out, many jobs in college.
so I'll send you a sleep code, you could take a look and explain to me how to put the conditionals so he wakes up at 8 o'clock to work and when he gets 8 o'clock he goes back to sleep! would help me a lot! thanks for listening.

You need 3 pieces of code and one replacement:
1) Ditch ds1302 and get yourself an RTC with an interrupt pin (like DS3231 which Jot suggests). It will make your life easier.
2) Setup your RTC to fire an interrupt every 12 hours.
3) Since you have successfully implemented a sleep mode, try to wake your Arduino up using a hardware interrupt. See Nick Gammon's guide for interrupts, and read carefully about waking your micro with an external interrupt. You can prototype it using a pushbutton, which will either connect your interrupt pin to GND or Vcc. Use an appropriate resistor as well. This guide has good information for starters.
To sum up: you'll have your Arduino sleep at all times and your RTC set to fire a hardware interrupt. When fired, the interrupt wakes Arduino, and the interrupt code will handle your measurements.


text:
SPI.H library to control APA102
I am trying to run a strip of APA102 addressable LED's using a Mini pro.
The same strip I can run using a raspberry pi using SPI so I know the Strip works and what data I need to send to get it running.
My current code is as follows and I have striped it back to the bare minimum as I see it.
It all compiles and runs but nothing on the LED strip. The stip only has data and clock that should be connected to the CLK and Data in to connect to the MOSI.
All i want is to be able to send a 32bit value,
I had also tried
uint32_t value = 0xE0ffffff

but again no luck
void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);

  SPI.begin();

  byte start = 0x00;
  SPI.transfer(start);
  SPI.transfer(start);
  SPI.transfer(start);
  SPI.transfer(start);

  SPI.transfer(0xEF);
  SPI.transfer(255);
  SPI.transfer(0);
  SPI.transfer(10);
}

Check here https://www.pololu.com/product/2552/resources. The AdaFruit library may be configured for HW SPI.

I have played with that Libuary and it works fine but I dont see any were you can configure it to use SPI, you can switch to FastGPIO but not SPI.

As I said, check the AdaFruit library https://github.com/adafruit/Adafruit_DotStar.

Apologies I clicked on the first Library, which was not the Adafruit one. Got it now and looking through it. Thank you

OK a fresh look and its all working OK now, I get a strange issue of when the code it uploaded to the Ardunio that random lights on the strip light up. but if I reset the Ardunio and power cycle the strip it all works as expected. Not sure what this behavior is but it only seems to happen after a upload when the serial link is connected. Anyhow thanks for the link, I am not using there library but looking though it I can see how they are doing it and they are doing a similar thing to me, i am writing 32bit vales using spi.transfer(buffer, size) and it seems to be good :)

I guess the random lights when uploading has to do with the SPI signals used while programming the flash. I would recommend disconnecting the LEDs while uploading, power down, connecting the LED and then powering up. Alternatively adding a chip select signal e.g. blocking the clock signal.

Let us continue this discussion in chat.

take a look at the datasheet, compare it vs. your code for any incompliance.
based on my quick reading, your code isn't consistent with the datasheet.
put the communications in a routine would help maintain uniformity.

Where is the issue with my code? the data sheet requires a 32bit start frame of zeros, followed by N number of Control fames which are them selves 32bit (brightness, RED, Green, Blue). once all control frames have been sent you need to send clock cycles to push the commands to the end of the strip (this is not needed for a single LED) . As I say the same frames work fine on a raspberry pi so its not the data structure thats an issue. As for putting it in a routine I will make this a libuary once I have the syntax right.


text:
Post Data Server from Arduino using Fuzzy Logic
Can somebody help me , when i run this code separately , no problem was found , but when i fuse it together , only fuzzy work and the data can't be sent to my server, sorry for my bad english
i already tried to separate them with function and give delay to make time for posting data , but maybe that not the real problem
#include "SoftwareSerial.h"
#include <dht.h>
#include <Fuzzy.h>
#define DEBUG true
#define dht_apin A1 // Analog Pin sensor is connected to
SoftwareSerial esp(6, 7);// RX, TX
String ssid = "BU SIS";
String password = "Bismillah";
dht DHT;
// Fuzzy
Fuzzy *fuzzy = new Fuzzy();
// FuzzyInputKudara
FuzzySet *urendah = new FuzzySet(0, 50, 50, 50);
FuzzySet *usedang = new FuzzySet(45, 60, 60, 75);
FuzzySet *utinggi = new FuzzySet(70, 70, 100, 100);
// FuzzyInputKtanah
FuzzySet *trendah = new FuzzySet(0, 50, 50, 50);
FuzzySet *tsedang = new FuzzySet(45, 60, 60, 75);
FuzzySet *ttinggi = new FuzzySet(70, 70, 100, 100);
// FuzzyInputSudara
FuzzySet *srendah = new FuzzySet(20, 27, 27, 31);
FuzzySet *stinggi = new FuzzySet(30, 35, 40, 40);
// FuzzyOutputKondisi
FuzzySet *tidak = new FuzzySet(0, 25, 25, 50);
FuzzySet *siram = new FuzzySet(50, 80, 100, 100);
String data;
String server = "192.168.100.11";
String uri = "/web/insertx.php";
String temp , hum;
int ftemp, fhum;
int tanah;
void setup() {
  Serial.begin(9600);
  esp.begin(9600);
  // Reset modul
  sendCommand("AT+RST\r\n", 1000, DEBUG);
  // Konfigurasikan sebagai Akses poin & Wifi
  sendCommand("AT+CWMODE=3\r\n", 1000, DEBUG);
  // Sesuaikan dengan SSID dan Password
  sendCommand("AT+CWJAP=\"BU SIS\",\"Bismillah\"\r\n", 10000, DEBUG);
  // Mendapatkan IP adress
  sendCommand("AT+CIFSR\r\n", 1000, DEBUG);
  // Konfigurasikan untuk multiple connection
  sendCommand("AT+CIPMUX=1\r\n", 1000, DEBUG);
    //   FuzzyInput
    FuzzyInput *kudara = new FuzzyInput(1);
    kudara->addFuzzySet(urendah);
    kudara->addFuzzySet(usedang);
    kudara->addFuzzySet(utinggi);
    fuzzy->addFuzzyInput(kudara);
    // FuzzyInput
    FuzzyInput *ktanah = new FuzzyInput(2);
    ktanah->addFuzzySet(trendah);
    ktanah->addFuzzySet(tsedang);
    ktanah->addFuzzySet(ttinggi);
    fuzzy->addFuzzyInput(ktanah);
    // FuzzyInput
    FuzzyInput *sudara = new FuzzyInput(3);
    sudara->addFuzzySet(srendah);
    sudara->addFuzzySet(stinggi);
    fuzzy->addFuzzyInput(sudara);
    // FuzzyOutput
    FuzzyOutput *kondisi = new FuzzyOutput(1);
    kondisi->addFuzzySet(tidak);
    kondisi->addFuzzySet(siram);
    fuzzy->addFuzzyOutput(kondisi);
    // Building FuzzyRule 3
    FuzzyRuleAntecedent *a3 = new FuzzyRuleAntecedent();
    a3->joinWithAND(urendah, tsedang);
    FuzzyRuleAntecedent *ktanah3 = new FuzzyRuleAntecedent();
    ktanah3->joinSingle(srendah);
    FuzzyRuleAntecedent *aa3 = new FuzzyRuleAntecedent();
    aa3->joinWithAND(a3, ktanah3);
    FuzzyRuleConsequent *maka3 = new FuzzyRuleConsequent();
    maka3->addOutput(siram);
    FuzzyRule *fuzzyRule3 = new FuzzyRule(3, aa3, maka3);
    fuzzy->addFuzzyRule(fuzzyRule3);
    // Building FuzzyRule 5
    FuzzyRuleAntecedent *a5 = new FuzzyRuleAntecedent();
    a5->joinWithAND(urendah, ttinggi);
    FuzzyRuleAntecedent *ktanah5 = new FuzzyRuleAntecedent();
    ktanah5->joinSingle(srendah);
    FuzzyRuleAntecedent *aa5 = new FuzzyRuleAntecedent();
    aa5->joinWithAND(a5, ktanah5);
    FuzzyRuleConsequent *maka5 = new FuzzyRuleConsequent();
    maka5->addOutput(siram);
    FuzzyRule *fuzzyRule5 = new FuzzyRule(5, aa5, maka5);
    fuzzy->addFuzzyRule(fuzzyRule5);
    // Building FuzzyRule 9
    FuzzyRuleAntecedent *a9 = new FuzzyRuleAntecedent();
    a9->joinWithAND(usedang, tsedang);
    FuzzyRuleAntecedent *ktanah9 = new FuzzyRuleAntecedent();
    ktanah9->joinSingle(srendah);
    FuzzyRuleAntecedent *aa9 = new FuzzyRuleAntecedent();
    aa9->joinWithAND(a9, ktanah9);
    FuzzyRuleConsequent *maka9 = new FuzzyRuleConsequent();
    maka9->addOutput(siram);
    FuzzyRule *fuzzyRule9 = new FuzzyRule(9, aa9, maka9);
    fuzzy->addFuzzyRule(fuzzyRule9);
    //   Building FuzzyRule 11
    FuzzyRuleAntecedent *a11 = new FuzzyRuleAntecedent();
    a11->joinWithAND(usedang, ttinggi);
    FuzzyRuleAntecedent *ktanaha11 = new FuzzyRuleAntecedent();
    ktanaha11->joinSingle(srendah);
    FuzzyRuleAntecedent *aa11 = new FuzzyRuleAntecedent();
    aa11->joinWithAND(a11, ktanaha11);
    FuzzyRuleConsequent *maka11 = new FuzzyRuleConsequent();
    maka11->addOutput(siram);
    FuzzyRule *fuzzyRule11 = new FuzzyRule(11, aa11, maka11);
    fuzzy->addFuzzyRule(fuzzyRule11);
    // Building FuzzyRule 12
    FuzzyRuleAntecedent *a12 = new FuzzyRuleAntecedent();
    a12->joinWithAND(usedang, stinggi);
    FuzzyRuleAntecedent *ktanaha2 = new FuzzyRuleAntecedent();
    ktanaha2->joinSingle(ttinggi);
    FuzzyRuleAntecedent *aa12 = new FuzzyRuleAntecedent();
    aa12->joinWithAND(a12, ktanaha2);
    FuzzyRuleConsequent *makaa2 = new FuzzyRuleConsequent();
    makaa2->addOutput(siram);
    FuzzyRule *fuzzyRule12 = new FuzzyRule(12, aa12, makaa2);
    fuzzy->addFuzzyRule(fuzzyRule12);
    // Building FuzzyRule 15
    FuzzyRuleAntecedent *a15 = new FuzzyRuleAntecedent();
    a15->joinWithAND(utinggi, srendah);
    FuzzyRuleAntecedent *ktanaha5 = new FuzzyRuleAntecedent();
    ktanaha5->joinSingle(tsedang);
    FuzzyRuleAntecedent *aa15 = new FuzzyRuleAntecedent();
    aa15->joinWithAND(a15, ktanaha5);
    FuzzyRuleConsequent *makaa5 = new FuzzyRuleConsequent();
    makaa5->addOutput(siram);
    FuzzyRule *fuzzyRule15 = new FuzzyRule(15, aa15, makaa5);
    fuzzy->addFuzzyRule(fuzzyRule15);
    // Building FuzzyRule 17
    FuzzyRuleAntecedent *a17 = new FuzzyRuleAntecedent();
    a17->joinWithAND(utinggi, ttinggi);
    FuzzyRuleAntecedent *ktanaha7 = new FuzzyRuleAntecedent();
    ktanaha7->joinSingle(srendah);
    FuzzyRuleAntecedent *aa17 = new FuzzyRuleAntecedent();
    aa17->joinWithAND(a17, ktanaha7);
    FuzzyRuleConsequent *makaa7 = new FuzzyRuleConsequent();
    makaa7->addOutput(siram);
    FuzzyRule *fuzzyRule17 = new FuzzyRule(17, aa17, makaa7);
    fuzzy->addFuzzyRule(fuzzyRule17);
  delay(10000);
}
void dataku() {
  DHT.read11(dht_apin);
  fhum = DHT.humidity;
  ftemp = DHT.temperature;
  tanah = analogRead(A0);
  tanah = map(tanah, 1023, 36, 100, 0);
  hum = String(fhum);
  temp = String(ftemp);
  fuzzy->setInput(1, fhum);
  fuzzy->setInput(2, tanah);
  fuzzy->setInput(3, ftemp);
  fuzzy->fuzzify();
  Serial.println(fhum);
  Serial.println(ftemp);
  Serial.println(tanah);
  Serial.print("\n\nKondisi: ");
  if (siram->getPertinence() > tidak->getPertinence()) {
    Serial.println("Siram\n");
    pinMode(10, OUTPUT);
    digitalWrite(10, LOW);
  } else {
    Serial.println("Tidak Siram\n");
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);
  };
  float output1 = fuzzy->defuzzify(1);
  data = "suhu=" + temp + " & udara=" + hum + " & tanah=" + tanah;// data sent must be under this form //name1=value1&name2=value2.
//    data = "suhu=10 & udara=20 & tanah=30";
  Serial.println(data);
}
void loop() {
  esp.println("AT+CIPSTART=0,\"TCP\",\"" + server + "\",80");//start a TCP connection.
  if ( esp.find("OK")) {
    Serial.println("Koneksi siap");
  };
  Serial.println("=>======================================");
  dataku();
  httppost();
  delay(5000);
}
void httppost () {
  String postRequest =
    "POST " + uri + " HTTP/1.1\r\n" +
    "Host: " + server + "\r\n" +
    "Connection: close\r\n" +
    "Content-Type: application/x-www-form-urlencoded\r\n" +
    //    "Content-Type: application/json;charset=UTF-8\r\n"+
    "Content-Length: " + data.length() + "\r\n" +
    "\r\n" + data;
  String sendCmd = "AT+CIPSEND=0";//determine the number of caracters to be sent.
  //Serial.println(postRequest);
  esp.print(sendCmd);
  esp.print(",");
  esp.println(postRequest.length());
  delay(200);
  if (esp.find(">")) {
    Serial.println("Sending.."); esp.print(postRequest);
    if ( esp.find("SEND OK")) {
      Serial.println("Packet sent");
      while (esp.available()) {
        String tmpResp = esp.readString();
        Serial.println(tmpResp);
      }
      // close the connection
      delay(3000);
      esp.println("AT+CIPCLOSE");
      Serial.println("PUTUS");
    }
    //    Serial.println(postRequest);
  }
  delay(4000);
  //  Serial.println(sendCmd + postRequest.length() );
}

String sendCommand(String command, const int timeout, boolean debug) {
  String response = "";
  esp.print(command);
  long int time = millis();
  while ( (time + timeout) > millis())  {
    while (esp.available())    {
      char c = esp.read();
      response += c;
    }
  }
  if (debug) {
    Serial.print(response);
  }
  return response;
}

Sketch uses 17524 bytes (54%) of program storage space. Maximum is 32256 bytes. Global variables use 832 bytes (40%) of dynamic memory, leaving 1216 bytes for local variables. Maximum is 2048 bytes.

Hint: Measure free memory after setup() i.e. call freeMemory() and print last in setup. https://learn.adafruit.com/memories-of-an-arduino/measuring-free-memory

06:39:14.727 -> AT+RST
06:39:14.727 -> busy p...
06:39:15.745 -> AT+CWMODE=3
06:39:15.745 -> busy p...
06:39:25.809 -> AT+CWJAP="BU SIS","Bismillah"
06:39:25.844 -> busy p...
06:39:25.844 -> OK
06:39:26.825 -> AT+CIFSR
06:39:26.825 -> 192.168.4.1
06:39:26.858 -> 192.168.100.30
06:39:26.858 -> OK
06:39:27.846 -> AT+CIPMUX=1
06:39:27.879 -> OK
06:39:27.879 -> 238
06:39:37.850 -> 238
06:39:38.019 -> Koneksi siap
06:39:38.019 -> =>======================================

06:39:38.053 -> 69
06:39:38.053 -> 28
06:39:38.087 -> 96
06:39:38.087 ->
06:39:38.087 ->
06:39:38.087 -> Kondisi: Siram
06:39:38.087 ->
06:39:38.087 -> 186
06:39:38.087 -> 96
06:39:38.123 -> 181
06:39:38.295 -> Sending..
06:39:48.283 -> 181
06:39:49.297 -> =>======================================
06:39:49.331 -> 71
06:39:49.331 -> 28
06:39:49.365 -> 96

did it means , my arduino can't handle that code together ?

The Arduino Uno has only 2K byte. That is one million times smaller than todays PCs. It is important to understand memory allocation and how to write code that does not consume as much memory. My guess was that you are very close to the limit and need to rewrite some sections to reduce the memory footprint. But first of all it is important to understand how much memory is used and where in the code.


text:
ARDUINO PROGRAM
I have a project that consists in measuring the mass of an object with a strain gauge HX711.
so I found an interesting Arduino program and the editing that goes with it.
but I have a problem, I manage to compile the program and then upload it but unfortunately my serial monitor still displays 0lbs.....
can you help me????
#include "HX711.h"

#define DOUT  3
#define CLK  2

HX711 scale;

float calibration_factor = -1242; //-7050 worked for my 440lb max scale setup

void setup() {
  Serial.begin(9600);
  Serial.println("HX711 calibration sketch");
  Serial.println("Remove all weight from scale");
  Serial.println("After readings begin, place known weight on scale");
  Serial.println("Press + or a to increase calibration factor");
  Serial.println("Press - or z to decrease calibration factor");

  scale.begin(DOUT, CLK);
  scale.set_scale();
  scale.tare(); //Reset the scale to 0

  long zero_factor = scale.read_average(); //Get a baseline reading
  Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
  Serial.println(zero_factor);
}

void loop() {

  scale.set_scale(calibration_factor); //Adjust to this calibration factor

  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 1);
  Serial.print(" lbs"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
  Serial.print(" calibration_factor: ");
  Serial.print(calibration_factor);
  Serial.println();

  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == '+' || temp == 'a')
      calibration_factor += 10;
    else if(temp == '-' || temp == 'z')
      calibration_factor -= 10;
  }
}

Hint: Start by removing 1 from Serial.print(scale.get_units(), 1);

yes and @MikaelPatel

I removed the variable but now my serial monitor no longer displays a value?
I would like him to give me the value of a weight of 1kg  .@MikaelPatel

To find the error you need to remove any possible source. Removing the number of decimal digits could help detect if you are measuring a small value. The next (or actual first) thing to check is the wiring and the power supply.

I have to check the power supply all is good so I will remove the decimal numbers but I don't see how this could help me? @MikaelPatel

even when trying to remove the decimal numbers I always stay at 0 …. @MikaelPatel

What is the calibration factor? And how did you calculate that? Or did you just copy that?

My guess (given that the device and wiring are working) is that the scaling/calibration factors are wrong for the weight interval you wish to measure. Please check these settings.

i calculate the calibration factor with another program that consiter to read only the calibration value! @Mikael Patel

Plese ..? @Mikael Patel


text:
How can I power an Arduino in a 3-phase environment?
I am working on a project which uses an Arduino board. Currently I am testing my device using 2-phase power and it works fine.  I want to use that device in agriculture fields where 3-phase power is available instead. How can I do this?

Typically low wattage accessory equipment in 3-phase systems is supplied by just two of the three wire phases, but you will need a power supply rated for the unusual voltage which results.

You do not want to connect your arduino to mains voltage, do you? So your question is probably about the powers supply you are using. As there is no arduino branded PSU you will have to give us more information about  that PSU and your local mains voltages. Otherwise it will be deleted.

The very short answer is that the Arduino board itself is designed to be powered by low-voltage DC (but you almost certainly already know this). So what you're really asking, I think, is "can you use the mains power supply that converts mains AC to DC on a three-phase supply?"
The answer to that is a guarded yes. You will need to confirm that you are connecting to a single phase (basically what you were doing in testing) and that the voltage is appropriate for your power adapter.
The abridged version of the gory details follows…
Three-phase supplies are almost always used for motor or other power applications – for a low power device like an Arduino (or even lighting or small appliances) you don't typically need three-phase. What is usually done is to take the power supply for those devices either from phase-to-neutral or phase-to-phase – depending on the configuration of the three-phase supply.
Wikipedia has an article on three-phase power that explains the common connection schemes (Y or star where the three phases are wired to a common point, and delta where they are wired in a triangle). What is significant is that you will typically get a high and a low voltage depending on how you connect to a three-phase system. For example in the US a common Y three-phase service will give you 120 V phase-to-neutral and 208 V phase-to-phase.
A true 3-phase (as in needs to connect to all three phases) low-voltage power supply will probably be quite expensive. But you also don't need one. Unless you are building an "industrial" device all you need is a "normal" low-voltage power supply that is designed for the voltage that you'll be connecting it to.
All you need to do is to confirm the voltage that you'll be using and check that your power supply is rated for it. Many low voltage supplies are designed to be "universal" and you'll see a rating like 100-240 V, 50-60 Hz. That's likely to work on most three-phase supplies as long as the connection isn't phase-to-phase in a part of the world where the high voltage is in the 400 V range.

There are a lot of 3-phase PSU. But in fact not many provide a voltage suitable for an arduino. Example: [http://www.pulspower.com/index.php?reqNav=product&objectId=21], which is a device using explicitely two phases of a three phase system, not from a two phase system. The manufacturer also has real 3-phase PSUs, but only with Vout beginning with 24V.

I'll correct what I wrote. Supplies like that exist, but if you're just doing something small with an Arduino are way bigger (and probably way more expensive) than what is required. The one you linked to is capable of providing 8 A at 12 V DC and is designed for mounting in a control enclosure. I'd expect you're paying a premium for that too. So it really depends on what you need – if you're looking for industrial grade gear, then that is a good example of what is available, but if you're just looking to provide power for an Arduino in a 3-phase environment, you can get by with less.

3-phase transformers are not cheap in general and low-voltage 3-phase transformers are very niche since taking such a small amount of power from 1 or 2 phases won't affect PF very much.

The one I linked is in the wild for about 100 € without VAT. Which is a pretty good price considering the specs. But that won't help our friend with tapping the powerline running over the rice field. (This could explain, why he has no neutral). :P

€100 is not a bad price, but still way more that you would have to spend to power an Arduino in a three phase environment. It really depends on what the goal is… But for prototyping I'd be tempted to spend less – at least to start with.


text:
Error in modification on MPU6050_DMP6
I made modifications on the original code of DMP6 MPU6050 to make it as I want. I took the standard libraries with it and they are helper_3dmath.h, MPU6050.cpp, MPU6050.h, MPU6050_6Axis_MotionApps20.h, I2C.cpp and finally I2c.cpp.
I made a main.ino and get_angles.cpp, which contains the code that has the function that calculates the angles out of the MPU6050. And a header file get_angles.h. I am getting an error that I can't figure out.
My main.ino is:
#include <Wire.h>
#include "get_angles.h"
angles imu ;
MPU6050 mpu;
void setup() {
    Wire.begin();
     TWBR = 24;
     Serial.begin(115200);
     mpu.initialize();
     mpu.setDMPEnabled(true);
     packetSize = mpu.dmpGetFIFOPacketSize();
}

void loop() {
  int yaw,pitch,roll;
  yaw =imu.get_yaw();
  pitch=imu.get_pitch();
  roll=imu.get_roll();
}

get_angles.cpp
#include "get_angles.h"
int angles::get_yaw() {
  MPU6050 mpu;
  mpuIntStatus = mpu.getIntStatus();
  fifoCount = mpu.getFIFOCount();
  // check for overflow (this should never happen unless our code is too inefficient)
  if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
    // reset so we can continue cleanly
    mpu.resetFIFO();
    Serial.println(F("FIFO overflow!"));
    // otherwise, check for DMP data ready interrupt (this should happen frequently)
  } else if (mpuIntStatus & 0x02) {
    // wait for correct available data length, should be a VERY short wait
    while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
    // read a packet from FIFO
    mpu.getFIFOBytes(fifoBuffer, packetSize);
    // track FIFO count here in case there is > 1 packet available
    // (this lets us immediately read more without waiting for an interrupt)
    fifoCount -= packetSize;
    mpu.dmpGetQuaternion(&q, fifoBuffer);
    mpu.dmpGetGravity(&gravity, &q);
    mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
    int yaw;
    yaw=ypr[0] * 180/M_PI;
    return(yaw);
  }
}

int angles::get_pitch() {
  MPU6050 mpu;
  mpuIntStatus = mpu.getIntStatus();
  fifoCount = mpu.getFIFOCount();
  // check for overflow (this should never happen unless our code is too inefficient)
  if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
    // reset so we can continue cleanly
    mpu.resetFIFO();
    Serial.println(F("FIFO overflow!"));
    // otherwise, check for DMP data ready interrupt (this should happen frequently)
  } else if (mpuIntStatus & 0x02) {
    // wait for correct available data length, should be a VERY short wait
    while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
    // read a packet from FIFO
    mpu.getFIFOBytes(fifoBuffer, packetSize);
    // track FIFO count here in case there is > 1 packet available
    // (this lets us immediately read more without waiting for an interrupt)
    fifoCount -= packetSize;
    mpu.dmpGetQuaternion(&q, fifoBuffer);
    mpu.dmpGetGravity(&gravity, &q);
    mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
    int pitch;
    pitch=ypr[1] * 180/M_PI;
    return(pitch);
  }
}

int angles::get_roll() {
  MPU6050 mpu;
  mpuIntStatus = mpu.getIntStatus();
  fifoCount = mpu.getFIFOCount();
  // check for overflow (this should never happen unless our code is too inefficient)
  if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
    // reset so we can continue cleanly
    mpu.resetFIFO();
    Serial.println(F("FIFO overflow!"));
    // otherwise, check for DMP data ready interrupt (this should happen frequently)
  } else if (mpuIntStatus & 0x02) {
    // wait for correct available data length, should be a VERY short wait
    while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
    // read a packet from FIFO
    mpu.getFIFOBytes(fifoBuffer, packetSize);
    // track FIFO count here in case there is > 1 packet available
    // (this lets us immediately read more without waiting for an interrupt)
    fifoCount -= packetSize;
    mpu.dmpGetQuaternion(&q, fifoBuffer);
    mpu.dmpGetGravity(&gravity, &q);
    mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
    int roll;
    roll=ypr[2] * 180/M_PI;
    return(roll);
  }
}

get_angles.h
#ifndef get_angles_H
#define get_angles_H

#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
static   uint16_t packetSize;
class angles {
  public:
    int get_yaw();
    int get_pitch();
    int get_roll();
  private:
    uint8_t mpuIntStatus;
    uint16_t fifoCount;     // count of all bytes currently in FIFO
    uint8_t fifoBuffer[64]; // FIFO storage buffer
    Quaternion q;           // [w, x, y, z] quaternion container
    VectorFloat gravity;    // [x, y, z] gravity vector
    float ypr[3];           // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector
};
#endif

The error I am facing:
Arduino: 1.6.5 (Windows 8.1), Board: "Arduino/Genuino Uno"

third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpInitialize()'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpPacketAvailable()'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetAccel(long*, unsigned char const*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetAccel(int*, unsigned char const*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetAccel(VectorInt16*, unsigned char const*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetQuaternion(long*, unsigned char const*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetQuaternion(int*, unsigned char const*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetQuaternion(Quaternion*, unsigned char const*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetGyro(long*, unsigned char const*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetGyro(int*, unsigned char const*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetGyro(VectorInt16*, unsigned char const*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetLinearAccel(VectorInt16*, VectorInt16*, VectorFloat*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetLinearAccelInWorld(VectorInt16*, VectorInt16*, Quaternion*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetGravity(VectorFloat*, Quaternion*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetEuler(float*, Quaternion*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetYawPitchRoll(float*, Quaternion*, VectorFloat*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpProcessFIFOPacket(unsigned char const*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpReadAndProcessFIFOPacket(unsigned char, unsigned char*)'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
third_iteration.cpp.o: In function `MPU6050::dmpInitialize()':
C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/MPU6050_6Axis_MotionApps20.h:325: multiple definition of `MPU6050::dmpGetFIFOPacketSize()'
get_angles.cpp.o:C:\Users\MOHAME~1\AppData\Local\Temp\build384877420483334776.tmp/helper_3dmath.h:56: first defined here
collect2.exe: error: ld returned 1 exit status
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

The error, if you read it, doesn't relate to any of those files, it relates to MPU6050_6Axis_MotionApps20.h. Maybe you should have included that file too?  Oh, and helper_3dmath.h

yeah i know that but i declare #include "MPU6050_6Axis_MotionApps20.h" in my header and in it the declearation of the other like helper_3dmath and the other libraries as i said before in the main post .... and btw that is the original dmp code so .. if i took this libraries and put besides jeff code it will work prefectly  @Majenko

Well, that i2cdev library code you have to treat with real kid gloves. Mess with it at your peril. The way it's been written breaks all the rules of good coding and the author should be strung up by his danglies. If he'd been in my employ and had written that code I'd have sacked him on the spot. Good luck with messing with it - you're a braver man than I. I'd start by re-writing the whole library suite properly.

i didn't missed with anything i just took his main and put it in cpp and make his decleration in header then called this class i have done in cpp file .... so i didn't miss with anything .... and that why i am really angry ... i didn't do anything to the code just copy and paste and the error is muilti-defination ... anyway thank you @Majenko

And that's all you really need to do to break it, it's written that poorly.  The whole problem can be summed up in four words: "Functions in Header Files"

ok ... i am in my first steps in coding ... if it is not rudeness can you tell me what i can do to take the original code and don't break it ... thanks in advance and of course make it parts as cpp and header  @Majenko

You need to split it all apart properly so that the functions aren't in the header files, but instead are in cpp files where they should be.