avrdude: stk500_paged_load(): (a) protocol error, expect=0x10, resp=0x90
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x0c
avrdude: verification error; content mismatch
avrdude: verification error; content mismatch
here is the program I was asked to send to the board. It is my understanding that these items were at one time working
Code: Select all
#include <LiquidCrystal.h>
#include <SPI.h>
#include <RH_RF69.h>
//This is code for Arduinos. You need Adafruit's RadioHead library to compile this.
//ard1 is the receiving side, ard2 is the transmiting side (with a button)
//*Only* ard2 can transmit
//Used to change messages + logic
#define transmit
//Used to control what pins we use
#define ard2
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
#ifdef ard1
const int rs = 5, en = 6, d4 = 7, d5 = 8, d6 = 9, d7 = 10;
#endif
#ifdef ard2
const int rs = 5, en = 6, d4 = 7, d5 = 8, d6 = 9, d7 = 4;
#endif
#ifdef receive
const char* text[] = {
//Each must be max. 16 characters in length, per row
"** THIS IS A **",
"** GEOCACHE **",
"*** GC798H9 ***",
"*** by BWJM ***",
"** WIRELESS **",
"** AMMO CANS **",
"To unlock the ",
"next stage, ",
"send a member of",
"your team to ",
"the transmitter ",
"to push button. ",
"Only when the ",
"button has been ",
"released will ",
"the solution ",
"be revealed. ",
" ",
"The transmitter ",
"can be found at "
};
const char* rText[] = {
//we don't need to space-pad here, (except for #1, because of something prior) because the strings always get bigger
"The button ",
"was pushed. ",
"The solution",
"will be shown",
"for 7 seconds.",
"Are you ready??",
};
#endif
#ifdef transmit
const char* text[] = {
"In order to ",
"unlock the final",
"stage of this ",
"geocache, ",
"push the button ",
"to transmit ",
"The coordinates ",
"will be shown ",
"at the first ",
"stage. "
};
#endif
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define RF69_FREQ 868.0
#ifdef ard1
#define RFM69_CS 4
#define RFM69_INT 3//??? I think?
#define RFM69_RST 2
#endif
#ifdef ard2
#define RFM69_CS 10
#define RFM69_INT 2 //??? I think?
#define RFM69_RST 3
#endif
// Singleton instance of the radio driver
RH_RF69 rf69(RFM69_CS, RFM69_INT);
int16_t packetnum = 0;
int loopStartMs;
int section = 0;
byte degree[8] = {
B01110,
B01010,
B01110,
B00000,
B00000,
B00000,
B00000,
};
#define RETRY_GAP 100
#define MAX_RETRYS 35
int lastRetry = -RETRY_GAP;
bool tryingToSend = false;
int retrys = 0;
void setup() {
lcd.begin(16, 2);
#ifdef receive
lcd.print("** THIS IS A *");
lcd.print("** GEOCACHE *");
#endif
#ifdef transmit
lcd.print("In order to *");
lcd.print("unlock the final");
#endif
lcd.createChar(0, degree);
pinMode(RFM69_RST, OUTPUT);
digitalWrite(RFM69_RST, LOW);
digitalWrite(RFM69_RST, HIGH);
delay(10);
digitalWrite(RFM69_RST, LOW);
delay(10);
if (!rf69.init()) {
lcd.setCursor(0,0);
// " "
lcd.print("Sorry, there was");
lcd.setCursor(0,1);
lcd.print("an error. (#1) ");
delay(200000);
while (1);
}
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM (for low power module)
// No encryption
if (!rf69.setFrequency(RF69_FREQ)) {
lcd.setCursor(0,0);
// " "
lcd.print("Error received, ");
lcd.setCursor(0,1);
lcd.print("but continuing. ");
delay(3000);
}
// If you are using a high power RF69 eg RFM69HW, you *must* set a Tx power with the
// ishighpowermodule flag set like this:
rf69.setTxPower(20, true); // range from 14-20 for power, 2nd arg must be true for 69HCW
// The encryption key has to be the same as the one in the server
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
rf69.setEncryptionKey(key);
lcd.setCursor(0,0);
int i;
for (i = 0; i <
#ifdef receive
10
#endif
#ifdef transmit
5
#endif
; i = i + 1) {
lcd.print(text[(2 * i)]);
lcd.setCursor(0,1);
lcd.print(text[(2 * i) + 1]);
lcd.setCursor(0,0);
delay(4000);
}
#ifdef receive
lcd.print("N 43");
lcd.write(byte(0));
lcd.print(" 16.693' ");
lcd.setCursor(0,1);
lcd.print("W 80");
lcd.write(byte(0));
lcd.print(" 22.823' ");
delay(6000);
lcd.setCursor(0,0);
lcd.print("Waiting for ");
lcd.setCursor(0,1);
lcd.print("button push... ");
#endif
#ifdef transmit
lcd.print("Push button. ");
lcd.setCursor(0,1);
lcd.print("Press firmly. ");
#endif
loopStartMs = millis();
}
void sendButtonPressed() {
retrys = 0;
tryingToSend = true;
}
#ifdef transmit
bool waitingForRelease = false;
bool buttonReleased = false;
#endif
void loop() {
//Perhaps 12 is for when data comes in?
//lcd.setCursor(0,0);
//lcd.print(digitalRead(12));
#ifdef transmit
if (tryingToSend) {
if (rf69.available()) {
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
rf69.recv(buf, &len);
tryingToSend = false;
retrys = 0;
lastRetry = -RETRY_GAP;
lcd.setCursor(0,0);
lcd.print("Coordinates are ");
lcd.setCursor(0,1);
lcd.print("shown at stage 1");
delay(20000);
} else if (retrys > MAX_RETRYS) {
//only do something if we've given enough time for a ack
if (millis() > (lastRetry + RETRY_GAP)) {
lcd.setCursor(0,0);
// " "
//lcd.print("Sorry, there was");
//lcd.setCursor(0,1);
//lcd.print("an error. (#2) ");
lcd.print("Push button. ");
lcd.setCursor(0,1);
lcd.print("Press firmly... ");
tryingToSend = false;
retrys = 0;
lastRetry = -RETRY_GAP;
//while (1);
}
} else if (millis() > (lastRetry + RETRY_GAP)) {
char radiopacket[2] = "a";
itoa(packetnum++, radiopacket+13, 10);
// Send a message!
rf69.send( (uint8_t *) radiopacket, strlen(radiopacket));
rf69.waitPacketSent();
retrys++;
delay(RETRY_GAP);
}
}
#endif
#ifdef receive
if (rf69.available()) {
//send a message to ack
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
rf69.recv(buf, &len);
char radiopacket[2] = "a";
itoa(packetnum++, radiopacket+13, 10);
// Send a message!
rf69.send( (uint8_t *) radiopacket, strlen(radiopacket));
rf69.waitPacketSent();
buttonPressed();
}
int curSection = ((millis() - loopStartMs) / 4000) % 5;
//lcd.setCursor(0,0);
//if ((millis() % 1000) > 50) {
// lcd.print((millis() - loopStartMs) * 4000);
//}
if ((curSection == 0) || (curSection == 1)) {
curSection = 0;
} else if (curSection == 2) {
curSection = 1;
} else {
curSection = 2;
}
if (curSection != section) {
section = curSection;
if (section == 0) {
lcd.setCursor(0,0);
lcd.print("Waiting for ");
lcd.setCursor(0,1);
lcd.print("button push... ");
} else if (section == 1) {
lcd.setCursor(0,0);
lcd.print("The transmitter ");
lcd.setCursor(0,1);
lcd.print("can be found at ");
} else {
lcd.setCursor(0,0);
lcd.print("N 43");
lcd.write(byte(0));
lcd.print(" 16.693' ");
lcd.setCursor(0,1);
lcd.print("W 80");
lcd.write(byte(0));
lcd.print(" 22.823' ");
}
}
#endif
#ifdef transmit
int buttonValue = analogRead(0);
lcd.setCursor(0,0);
//lcd.print(buttonValue);
if ((buttonValue < 999) && !waitingForRelease && !buttonReleased) {
//don't update display if we don't need to
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Release button. ");
waitingForRelease = true;
} else if ((buttonValue > 1005) && waitingForRelease && !buttonReleased) {
waitingForRelease = false;
lcd.setCursor(0,1);
lcd.print("Transmitting... ");
sendButtonPressed();
//delay(4000);
}
#endif
}
#ifdef receive
void buttonPressed() {
int j;
lcd.setCursor(0,0);
for (j = 0; j < 3; j = j + 1) {
lcd.print(rText[(2 * j)]);
lcd.setCursor(0,1);
lcd.print(rText[(2 * j) + 1]);
lcd.setCursor(0,0);
delay(4000);
}
lcd.print("N 43");
lcd.write(byte(0));
lcd.print(" 16.638' ");
lcd.setCursor(0,1);
lcd.print("W 80");
lcd.write(byte(0));
lcd.print(" 22.734' ");
delay(7000);
lcd.setCursor(0,0);
lcd.print("Waiting for ");
lcd.setCursor(0,1);
lcd.print("button push... ");
loopStartMs = millis();
section = 0;
}
#endif