I created a battery tester with an attiny85. I am getting this error message and I don't know why. I recently switched computers and my old, non working computer had all my arduino programs and sketches. I know this code works as I have a working battery tester using this same program. I emailed the sketch to myself and opened it in my new computer. I did download the Tiny4kOLED library. Any ideas why I get this message?
The error message also says:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c:88:16: error: 'SDA' undeclared (first use in this function)
digitalWrite(SDA, 1);
Here is the code
#include <Tiny4kOLED.h>
int redPin = 1;
int greenPin = 3;
int analogValue = 0;
float voltage = 0;
int ledDelay = 1000;
// ============================================================================
void setup() {
// Put your own setup code here, to run once.
// Send the initialization sequence to the oled. This leaves the display turned off
oled.begin();
// Two rotations are supported,
// The begin() method sets the rotation to 1.
//oled.setRotation(0);
// Some newer devices do not contain an external current reference.
// Older devices may also support using the internal curret reference,
// which provides more consistent brightness across devices.
// The internal current reference can be configured as either low current, or high current.
// Using true as the parameter value choses the high current internal current reference,
// resulting in a brighter display, and a more effective contrast setting.
//oled.setInternalIref(true);
// Clear the memory before turning on the display
oled.clear();
// Turn on the display
oled.on();
// Switch the half of RAM that we are writing to, to be the half that is non currently displayed
oled.switchRenderFrame();
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
/* ------------------------------
* Show screen with all pixels ON
* ------------------------------
*/
// Fill screen with color
// As we're setting every pixel, there is no need to clear the previous contents.
//oled.fill(0xFF);
// Swap which half of RAM is being written to, and which half is being displayed
// This is equivalent to calling both switchRenderFrame and switchDisplayFrame
//oled.switchFrame();
//delay(1000);
/* -------------------------------
* Show screen with all pixels OFF
* -------------------------------
*/
// Clear the non-displayed half of the memory to all black
//oled.clear();
// Swap which half of RAM is being written to, and which half is being displayed
// oled.switchFrame();
//delay(1000);
/* -----------------------------------------
* Show screen with two different font sizes
* -----------------------------------------
*/
// Clear the non-displayed half of the memory to all black
// (The previous clear only cleared the other half of RAM)
oled.clear();
// The characters in the 8x16 font are 8 pixels wide and 16 pixels tall
// 2 lines of 16 characters exactly fills 128x32
oled.setFont(FONT8X16);
// Position the cusror
// usage: oled.setCursor(X IN PIXELS, Y IN ROWS OF 8 PIXELS STARTING WITH 0);
oled.setCursor(32, 0);
// Write the text to oled RAM (which is not currently being displayed)
// Wrap strings in F() to save RAM!
oled.print(F("Voltage"));
// The characters in the 6x8 font are 6 pixels wide and 8 pixels tall
// 4 lines of 21 characters only fills 126x32
oled.setFont(FONT6X8);
// Position the cusror
// Two rows down because the 8x16 font used for the last text takes two rows of 8 pixels
oled.setCursor(13, 2);
// Write the text to oled RAM (which is not currently being displayed)
oled.print(F(""));
// Position the cusror
// Cursor X is in pixels, and does not need to be a multiple of the font width
oled.setCursor(16, 3);
// Write the text to oled RAM (which is not currently being displayed)
oled.print(F(""));
// Swap which half of RAM is being written to, and which half is being displayed
oled.switchFrame();
delay(10);
analogValue = analogRead(A2);
voltage = 0.0048*analogValue;
oled.println(voltage);
if( voltage >= 1.6 )
setColor(0, 255, 0); //green LED color
else if (voltage > 1.2 && voltage < 1.6)
setColor(255, 255, 0); // yellow LED color
else if( voltage <= 1.2)
setColor(255, 0, 0); // red LED color
oled.clear();
}
void setColor(int red, int green, int blue)
{
analogWrite(redPin, red);
analogWrite(greenPin, green);
//analogWrite(bluePin, blue);
}