Hi everyone,
I am trying to connect an ATTINY84 to a TEA5767 radio and a LCD via PCF8574 over I2C. I have been able to successfully upload code that runs either the TEA5767 OR the LCD via PCF8574, but not both at the same time.
I just tried something different before posting. I commented out all the LCD code and removed the PCF8574 SDA and SCL wires and the radio worked. When I put the wires back in without any change to the code, there is nothing from the radio again.
Previously, I used the TEA5767 with a LCD without PCF8574, which worked fine. Now I want more pins available and changing my display to I2C seemed like an easy solution. I could switch to an Atmega board with more pins, but then I wouldn’t learn why my current approach isn’t working. Plus I would probably have the same problem.
Details:
(See the sample code below) Currently the LCD works as expected but there is nothing coming from the radio.
I am using the following boards:
Shorter version of my current code:
#include <Arduino.h>
#include <Wire.h>
#include <LCD-I2C.h>
LCD_I2C lcd(0x27, 16, 2);
void setFrequency(float frequency) {
frequency /= 10;
unsigned int freqB = 4 * (frequency * 1000000 + 225000) / 32768;
byte freqH = freqB >> 8;
byte freqL = freqB & 0XFF;
// printing the frequency to the LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("F: ");
lcd.setCursor(3, 0);
lcd.print(frequency);
Wire.beginTransmission(0x60);
Wire.write(freqH);
Wire.write(freqL);
Wire.write(0xB0);
Wire.write(0x10);
Wire.write(0x00);
Wire.endTransmission();
delay(100);
}
void setup() {
Wire.begin();
lcd.begin(&Wire);
lcd.display();
lcd.backlight();
lcd.print("LCD online!");
delay(3000);
setFrequency(893);
delay(2000);
}
void loop() {
setFrequency(905);
delay(3000);
setFrequency(913);
delay(3000);
setFrequency(893);
delay(3000);
}
platform.ini:
[env]
platform = atmelavr
board = attiny84
board_build.f_cpu = 1000000UL
framework = arduino
upload_protocol = custom
upload_port = /dev/ttyACM0
upload_speed = 9600
board_fuses.lfuse = 0x62
board_fuses.hfuse = 0xDF
board_fuses.efuse = 0xFF
platform_packages=
platformio/tool-avrdude@^1.70200.0
lib_deps =
hasenradball/LCD-I2C@^1.0.0
[env:usbasp]
upload_flags =
-C
${platformio.packages_dir}/tool-avrdude/avrdude.conf
-p
$BOARD_MCU
-P
$UPLOAD_PORT
-b
$UPLOAD_SPEED
-c
usbasp
-B 10
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i