HI, I am using an FTDI USB to TTL Converter to program an Arduino Pro Mini with an UpTime Counter code for a 1602 BLUE LCD 16x2 HD44780 with IIC I2C Serial Interface Adapter Module Display.
#include <Wire.h>
//#include <WireIMXRT.h>
//#include <WireKinetis.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
#define SDA A4//DIO
#define SCL A5//CLK
//hd44780_I2Cexp display(SCL,SDA);// instead of TM1637Display
/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x3F for PCF8574AT with A0,A1,A0 address line open, default setting.
// Set the pins on the I2C chip used for LCD connections:
// (addr, en,rw,rs,d4,d5,d6,d7,bl,blpol)
hd44780_I2Cexp lcd(0x3F);// declare lcd object: auto locate & auto config expander chip
const int LCD_COLS = 16;
const int LCD_ROWS = 2; //(2,1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address; we many end up changing it to 2, 3, 4, 5, 6, 7 instead
// im unsure if this address is for the 8-bit or the 4 bit; we need the 4 bit
// we may also asign the address as lcd(0x3F, 16,2); sets the LCD address to Ox3F as well( programmingboss)
const int REED_PIN = 2;
int is_timing=0; // // 1 means we are timing the interval between triggers; 0 means we are not
unsigned long start_time; // stores the start of the timing interval
void setup() {
// put your setup code here, to run once: sets up pin read mode and LCD display
Serial.begin(9600); // Used to type in characters
pinMode(REED_PIN, INPUT_PULLUP);
lcd.begin(16,2); // initialize the lcd for 16 chars 2 lines, turn on backlight
lcd.backlight();// keep backlight on?
//----characters for display----
//The positions on the screen are indexed starting with (0,0) in the top-left position.
//The first argument of setCursor() specifies which column number, and the second specifies which row number.
//By default, the starting location is (0,0).lcd.setCursor(6,0);// sets cursor on character 6, line 0
//lcd.print(millis()/1000);// unsure if I need for settign up count up
//delay();// figure out the time max; no longer need
lcd.setCursor(4,1);// moves LCD cursor to character 4, line 1
lcd.print("MOTE SHARK TIMER");//prints that phrase on screen
// originally I had "FREE SHARK " in () but I learned
// that there is no max time a shark can be on the line
// it is more as if the longer the shark is on the line, the more stressed it is likely to be
// ------- Quick 3 blinks of backlight ------------- no longer needed since no max time shark can be on line
//for(int i = 0; i< 3; i++)
//lcd.backlight();
//delay(250);
//lcd.noBacklight();
//delay(250);
//lcd.setBrightness(0x0f);// may not be needed since we have a potentiometer on the back of the display
lcd.clear();
int is_timing = 0;
}
void loop() {
// put your main code here, to run repeatedly:
int proximity = digitalRead(REED_PIN); // when sensor is close to the trigger
// if (proximity == HIGH) {
// the magnet is far from the reed switch
if (is_timing == 0) {
// trigger the start of the timing interval
is_timing = 1; // we are now timing the interval
start_time = millis(); // record the current time as the start of the interval
} else {
// update the LED display
unsigned long elapsed_time = millis() - start_time;
int seconds = elapsed_time / 1000;
int hours = seconds / 3600;
int minutes = (seconds - hours * 3600) / 60;
// print uptime in HH:MM:SS format
if(hours > 99)
hours %= 100; // limit hr to 0-99
// Print class does not support fixed width formatting
// so insert a zero if number smaller than 10
// if(hours < 10)
// outdev.write('0');
//outdev.print((int)hours);
//outdev.write(':');
// if(minutes < 10)
// outdev.write('0');
// outdev.print((int)minutes);
// outdev.write(':');
// if(seconds < 10)
// outdev.write('0');
// outdev.print((int)seconds);
}
//lcd.print(minutes, 0b01000000, true, 2, 2);
//lcd.print(hours, 0b01000000, true, 2, 0);
//}
// } else {
// the magnet is close to the reed switch
if (is_timing == 1) {
// triggers the end of the timing interval
is_timing = 0;
lcd.clear();
} else {
// we are not currently timing, so just chill
lcd.clear();
}
I have two issues to address:
- The code will not upload. The error message that appears is below.
Sketch uses 7060 bytes (22%) of program storage space. Maximum is 30720 bytes.
Global variables use 510 bytes (24%) of dynamic memory, leaving 1538 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x1b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x1b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x1b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x1b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x1b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x1b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x1b
Failed uploading: uploading error: exit status 1
I have searched through this forum community for solutions and have already tried burning the bootloader and confirming the correct port, board, processor, and programmer addresses. I have also tried updating Arduino and my computer, as well as changing Pro Minis. I have three Pro Minis in my possession and the code only downloads on one of them. How can I get it to upload on the other Pro Minis?
- The code does not do as expected. The display powers on, but there is no data output on the screen. I want a count-up timer to display on the LCD screen, in HH:MM:SS, when a magnet is not in proximity of the reed switch in the circuit. I also want the words "MOTE SHARK TIMER" to display on the screen when the display is powered on. Below is a picture of the schematic.
The LCD Display --> ProMini
GRD-->GRD
VCC--> RAW
SDA--> A4
SCL--> A5
A 9V battery is the power source. It is connected to the GRD and RAW of the Pro Mini. The REED Switch connects to the Pro Mini via GRD and D2.
What changes to the code could I make? How would I identify the SDA and SCL pins differently?