Good evening, recently I have been receiving problems with the Arduino IDE software.
One of the problems is that the output shows:
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
Failed uploading: uploading error: exit status 1
This problem has appeared a few different times, and I was able to fix it for some time since I had to invert some cables. However, I'm not sure what to do this time.
Another problem is that the upload is taking too much time, and I don't think it will eventually upload.
I appreciate any help very much, and thank you in advance.
#include <PCM.h>
#include <SoftwareSerial.h>
const unsigned char sample[] PROGMEM = {
//PCM Data is in the bracket
};
#define fsrAnalogPin A0
const int threshold = 25;
int lvl;
unsigned long playbackStartTime = 0;
int playbackDuration = 4000;
void setup(){
Serial.begin(9600);
}
void loop(){
byte resistance = 0;
lvl = analogRead(fsrAnalogPin);
Serial.println(lvl);
if(fsrAnalogPin >= threshold && (millis() - playbackStartTime >= playbackDuration)){
startPlayback(sample, sizeof(sample));
playbackStartTime = millis();
}
delay(100);
}
The project that I'm doing is that whenever the value of the pressure sensor exceeds the threshold, it will trigger an alarm. I have included a HC-06 module in the circuit to send data from the fsr to an app in the MIT App Inventor software. (Originally, I had the two codes separated, but I combined the two of them to facilitate the coding) The app is sent to app by the Arduino, but the alarm is not triggered. What could I possibly do to fix this?
Hi @astato30. Please add a reply here on this forum thread to tell us which Arduino board you are using.
Please be as specific as possible as some Arduino boards with similar names have significant differences and the forum helpers can only provide effective assistance if we are aware of which one is being used.
If you aren't sure how to describe which board you are using, you can provide the link to the online product listing you bought the board from and we'll proceed based on the information found there.
Which pins on the Arduino board are connected to the HC-06 module?
Hi @ptillisch. The HC-06 is connected to 0,1 or the Tx,Rx pins.
The board I'm using is an Arduino Uno R3:
BN: Arduino Uno
VID: 0x2341
PID:0x0043
SN: 34239313335351A0C081
That is the cause of the upload failure. Those pins are used to communicate with the computer over the serial port. Connecting anything to these pins can interfere with the board's communications with the computer, including uploads.
It seems that you had some idea of using the "SoftwareSerial" library in the sketch, but then you never actually used it. This library would allow you to connect the HC-06 module to pins other than 0 and 1 on the UNO.
The other possible solution would be to disconnect the HC-06 module from the UNO board before each upload and then reconnect it after. However, you should be aware that if you do that you won't be able to use Serial.println in your sketch to print information to Serial Monitor in order to get an idea of what is happening in your program.
I changed the pins of the HC-06 to 11,12 but the pressure sensor doesn't send the data to the app. I previously had the HC-06 on pins 0,1 and it worked. I'm just confused why the alarm doesn't go off when I apply pressure on the sensor, and send the data to the app.
Thank you, it works after I remove the HC-06 before uploading the code. I was wondering, when I was able to get the first connection between the app and the Arduino, the pressure from the sensor was at the 100s or 200s. However, it is in the range of 30s-60s. By any chance do you know why that is.
If you want to create a serial interface on pins 11 and 12, then you have to adjust your code accordingly. It isn't just going to magically work by moving the HC-06 module connections to different pins alone. If you want to do this then you must carefully study the SoftwareSerial library's documentation to understand how it works:
Also, does the <SoftwareSerial.h> send everything in the code to the app via Bluetooth. If so, what I can do to prevent the Arduino from sending the conditional statement to the app?
Not for the values to change but to send the value to the Bluetooth. Below a quick demo; it reads A0, sends the value to the HC-06 on pins 11 and 12 and sends the same value over USB for debugging.
#include <SoftwareSerial.h>
const byte rxPin = 11;
const byte txPin = 12;
// Set up a new SoftwareSerial object
SoftwareSerial btSerial (rxPin, txPin);
void setup()
{
// communication with PC
Serial.begin(115200);
// bluetooth communication
btSerial.begin(9600);
}
void loop()
{
uint16_t val = analogRead(A0);
// send to bluetooth
btSerial.println(val);
// send to PC
Serial.println(val);
delay(1000);
}
The SoftwareSerial object is called btSerial so it reflects its use.