Hi all,
I am using an ATTiny3217 QFN package and I need some clafification on which pins SDA and SCL are. The code below used to work but for some reason I have no clock signal to the display.
Any ideas.
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#include <EEPROM.h>
//#include <GEARS_TNR.h>
//#include <GEARS_TNR_INV.h>
//#include <GEARS_NAVILU.h>
//#include <GEARS_NAVILU_INV.h>
//#include <GEARS_C059.h>
#include <GEARS_C059_INV.h>
#define OLED_RESET 4
int GearStart;
int Gear;
int SetGear;
int sensorVal;
int out1 = (PIN_PC0); //17;
int out2 = (PIN_PC1); //18;
int out3 = (PIN_PC2); //19;
//int out4 = 15; //Unsure why this is here, forgot why I put it here.
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);
void setup()
{
delay(500); //wait to settle
pinMode(out1, OUTPUT);
pinMode(out2, OUTPUT);
pinMode(out3, OUTPUT);
// pinMode(out4, OUTPUT);
// Read sensor value
sensorVal = analogRead1(PIN_PC5);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //or 0x3D
display.setRotation(1);
//Save Gear to EEPROM
SetGear = EEPROM.read(0); //Load gear from EEPROM
if (SetGear == 0) {
Set_ATRE_Gear();
}
if (sensorVal <= 665 )
{
// No Change
Gear = EEPROM.read(0); //Load gear from EEPROM
}
else if (sensorVal > 665 and sensorVal <= 800)
{
Gear = 1; //4th Gear
}
else if (sensorVal > 800 and sensorVal <= 905)
{
Gear = 2; //5th Gear
}
else if (sensorVal > 905 and sensorVal <= 980)
{
Gear = 3; //6th Gear
}
EEPROM.update(0, Gear); // Only writes if different
switch (Gear)
{
case 1: digitalWrite(out1, HIGH); break;
case 2: digitalWrite(out2, HIGH); break;
case 3: digitalWrite(out3, HIGH); break;
}
}
void loop()
{
// digitalWrite (out4, LOW);
// Read sensor value
sensorVal = analogRead1(PIN_PC5);
Gear = EEPROM.read(0); //Load gear from EEPROM
if (sensorVal > 300)
switch (Gear)
{
case 1: digitalWrite(out1, HIGH); break;
case 2: digitalWrite(out2, HIGH); break;
case 3: digitalWrite(out3, HIGH); break;
}
if (sensorVal > 300 and sensorVal <= 420)
{ display.clearDisplay (); //for Clearing the display
display.drawBitmap (0, 0, GEAR1, 64, 128, 1);
display.display ();
}
else if (sensorVal > 420 and sensorVal <= 540)
{ display.clearDisplay (); //for Clearing the display
display.drawBitmap (0, 0, GEAR2, 64, 128, 1);
display.display ();
}
else if (sensorVal > 540 and sensorVal <= 665)
{ display.clearDisplay(); //for Clearing the display
display.drawBitmap (0, 0, GEAR3, 64, 128, 1);
display.display ();
}
else if (sensorVal > 665 and sensorVal <= 800)
{ display.clearDisplay (); //for Clearing the display
display.drawBitmap (0, 0, GEAR4, 64, 128, 1);
display.display ();
}
else if (sensorVal > 800 and sensorVal <= 905)
{ display.clearDisplay (); //for Clearing the display
display.drawBitmap (0, 0, GEAR5, 64, 128, 1);
display.display ();
}
else if (sensorVal > 905 and sensorVal <= 980)
{ display.clearDisplay (); //for Clearing the display
display.drawBitmap (0, 0, GEAR6, 64, 128, 1);
display.display ();
}
else if (sensorVal > 980)
{
digitalWrite(out1, LOW);
digitalWrite(out2, LOW);
digitalWrite(out3, LOW);
display.clearDisplay (); //for Clearing the display
display.drawBitmap (0, 0, GEAR7, 64, 128, 1);
display.display ();
}
}
void Set_ATRE_Gear()
{
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("");
display.println("YOU");
display.println("NEED");
display.println("TO");
display.println("SET");
display.println("YOUR");
display.println("GEAR!");
display.display();
delay(5000);
}```