I am pretty much brand new at this. I am trying to run a sketch that flashes various LEDs and also runs a OLED screen. I can separate them and do just the LEDs or just the OLED screen. But obviously since I'm here and not in the bedroom with my wife, I am having a hell of a time getting them to work together.
The errors Im getting are as follows
C:\Users\Jolene\AppData\Local\Temp\ccapSHuO.ltrans0.ltrans.o: In function main': C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:46: undefined reference to
loop'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Mega or Mega 2560.
the sketch Im running is
// Screen dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128 // Change this to 96 for 1.27" OLED.
// You can use any (4 or) 5 pins
#define SCLK_PIN 37
#define MOSI_PIN 39
#define DC_PIN 35
#define CS_PIN 31
#define RST_PIN 33
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>
#include <Arduino.h>
// Option 1: use any pins but a little slower
Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, CS_PIN, DC_PIN, MOSI_PIN, SCLK_PIN, RST_PIN);
// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
//Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &SPI, CS_PIN, DC_PIN, RST_PIN);
float p = 3.1415926;
int led04 = 04; // the PWM pin the LED is attached to
int led05 = 05; // the PWM pin the LED is attached to
int led06 = 06; // the PWM pin the LED is attached to
int led07 = 07; // the PWM pin the LED is attached to
int led2 = 2; // the PWM pin the LED is attached to
int led3 = 3; // the PWM pin the LED is attached to
int led10 = 10; // the PWM pin the LED is attached to
int brightness4 = 75; // how bright the c white LED is
int fadeAmount4 = 0; // how many points to fade the c white LED by
int brightness5 = 2; // how bright the yellow LED is
int fadeAmount5 = 6; // how many points to fade the yellow LED by
int brightness6 = 4; // how bright the red LED is
int fadeAmount6 = 2; // how many points to fade the red LED by
int brightness7 = 6; // how bright the green LED is
int fadeAmount7 = 3; // how many points to fade the green LED by
int brightness2 = 5; // how bright the blue LED is
int fadeAmount2 = 5; // how many points to fade the blue LED by
int brightness3 = 210; // how bright the b white LED is
int fadeAmount3 = 178; // how many points to fade the b white LED by
int brightness10 = 5; // how bright the red LED is
int fadeAmount10 = 17; // how many points to fade the red LED by
int randNumber;
int PrintTest;
// the setup routine runs once when you press reset:
void setup(){
// declare pin 04 to be an output:
pinMode(led04, OUTPUT);
// declare pin 05 to be an output:
pinMode(led05, OUTPUT);
// declare pin 06 to be an output:
pinMode(led06, OUTPUT);
// declare pin 07 to be an output:
pinMode(led07, OUTPUT);
// declare pin 02 to be an output:
pinMode(led2, OUTPUT);
// declare pin 03 to be an output:
pinMode(led3, OUTPUT);
// declare pin 10 to be an output:
pinMode(led10, OUTPUT);
void setup(void);
Serial.begin(9600);
Serial.print("hello!");
tft.begin();
Serial.println("init");
uint16_t time = millis();
tft.fillRect(0, 0, 128, 128, BLACK);
time = millis() - time;
Serial.println(time, DEC);
delay(500);
tft.invert(true);
delay(100);
tft.invert(false);
delay(100);
//a single pixel
tft.drawPixel(tft.width()/2, tft.height()/2, GREEN);
delay(500);
// line draw test
testlines(YELLOW);
delay(500);
// optimized lines
testfastlines(RED, BLUE);
delay(500);
testdrawrects(GREEN);
delay(1000);
testfillrects(YELLOW, MAGENTA);
delay(1000);
tft.fillScreen(BLACK);
testfillcircles(10, BLUE);
testdrawcircles(10, WHITE);
delay(1000);
testroundrects();
delay(500);
testtriangles();
delay(500);
Serial.print("done!");
delay(500);
}
void testlines(uint16_t color) {
tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width()-1; x+=6) {
tft.drawLine(0, 0, x, tft.height()-1, color);
}
for (uint16_t y=0; y < tft.height()-1; y+=6) {
tft.drawLine(0, 0, tft.width()-1, y, color);
}
tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width()-1; x+=6) {
tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color);
}
for (uint16_t y=0; y < tft.height()-1; y+=6) {
tft.drawLine(tft.width()-1, 0, 0, y, color);
}
tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width()-1; x+=6) {
tft.drawLine(0, tft.height()-1, x, 0, color);
}
for (uint16_t y=0; y < tft.height()-1; y+=6) {
tft.drawLine(0, tft.height()-1, tft.width()-1, y, color);
}
tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width()-1; x+=6) {
tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color);
}
for (uint16_t y=0; y < tft.height()-1; y+=6) {
tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color);
}
}
void testdrawtext(char *text, uint16_t color) {
tft.setCursor(0,0);
tft.setTextColor(color);
tft.print(text);
}
void testfastlines(uint16_t color1, uint16_t color2) {
tft.fillScreen(BLACK);
for (uint16_t y=0; y < tft.height()-1; y+=5) {
tft.drawFastHLine(0, y, tft.width()-1, color1);
}
for (uint16_t x=0; x < tft.width()-1; x+=5) {
tft.drawFastVLine(x, 0, tft.height()-1, color2);
}
}
void testdrawrects(uint16_t color) {
tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.height()-1; x+=6) {
tft.drawRect((tft.width()-1)/2 -x/2, (tft.height()-1)/2 -x/2 , x, x, color);
}
}
void testfillrects(uint16_t color1, uint16_t color2) {
tft.fillScreen(BLACK);
for (uint16_t x=tft.height()-1; x > 6; x-=6) {
tft.fillRect((tft.width()-1)/2 -x/2, (tft.height()-1)/2 -x/2 , x, x, color1);
tft.drawRect((tft.width()-1)/2 -x/2, (tft.height()-1)/2 -x/2 , x, x, color2);
}
}
void testfillcircles(uint8_t radius, uint16_t color)
{
for (uint8_t x=radius; x < tft.width()-1; x+=radius2) {
for (uint8_t y=radius; y < tft.height()-1; y+=radius2) {
tft.fillCircle(x, y, radius, color);
}
}
}
void testdrawcircles(uint8_t radius, uint16_t color) {
for (uint8_t x=0; x < tft.width()-1+radius; x+=radius2) {
for (uint8_t y=0; y < tft.height()-1+radius; y+=radius2) {
tft.drawCircle(x, y, radius, color);
}
}
}
void testtriangles() {
tft.fillScreen(BLACK);
int color = 0xF800;
int t;
int w = tft.width()/2;
int x = tft.height();
int y = 0;
int z = tft.width();
for(t = 0 ; t <= 15; t+=1) {
tft.drawTriangle(w, y, y, x, z, x, color);
x-=4;
y+=4;
z-=4;
color+=100;
}
}
void testroundrects() {
tft.fillScreen(BLACK);
int color = 100;
int x = 0;
int y = 0;
int w = tft.width();
int h = tft.height();
for(int i = 0 ; i <= 24; i++) {
tft.drawRoundRect(x, y, w, h, 5, color);
x+=2;
y+=3;
w-=4;
h-=6;
color+=1100;
Serial.println(i);
}
void tftPrintTest();
{
tft.fillScreen(BLACK);
tft.setCursor(0, 5);
tft.setTextColor(RED);
tft.setTextSize(1);
tft.println("Hello World!");
tft.setTextColor(YELLOW);
tft.setTextSize(2);
tft.println("Hello World!");
tft.setTextColor(BLUE);
tft.setTextSize(3);
tft.print(1234.567);
delay(1500);
tft.setCursor(0, 5);
tft.fillScreen(BLACK);
tft.setTextColor(WHITE);
tft.setTextSize(0);
tft.println("Hello World!");
tft.setTextSize(1);
tft.setTextColor(GREEN);
tft.print(p, 6);
tft.println(" Want pi?");
tft.println(" ");
tft.print(8675309, HEX); // print 8,675,309 out in HEX!
tft.println(" Print HEX!");
tft.println(" ");
tft.setTextColor(WHITE);
tft.println("Sketch has been");
tft.println("running for: ");
tft.setTextColor(MAGENTA);
tft.print(millis() / 1000);
tft.setTextColor(WHITE);
tft.print(" seconds.");
}
//
/*!
@brief Renders a simple test pattern on the screen
*/
//
void lcdTestPattern(void);
{
static const uint16_t PROGMEM colors[] =
{ RED, YELLOW, GREEN, CYAN, BLUE, MAGENTA, BLACK, WHITE };
for(uint8_t c=0; c<8; c++) {
tft.fillRect(0, tft.height() * c / 8, tft.width(), tft.height() / 8,
pgm_read_word(&colors[c]));
void loop();
{
// set the brightness of pins:
analogWrite(led04, brightness4);
analogWrite(led05, brightness5);
analogWrite(led06, brightness6);
analogWrite(led07, brightness7);
analogWrite(led2, brightness2);
analogWrite(led3, brightness3);
analogWrite(led10, brightness10);
// change the brightness for next time through the loop:
brightness4 = brightness4 + fadeAmount4;
brightness5 = brightness5 + fadeAmount5;
brightness6 = brightness6 + fadeAmount6;
brightness7 = brightness7 + fadeAmount7;
brightness2 = brightness2 + fadeAmount2;
brightness3 = brightness3 + fadeAmount3;
brightness10 = brightness10 + fadeAmount10;
}
// reverse the direction of the fading at the ends of the fade:
if (brightness4 <= 0 || brightness4 >= 250) {
fadeAmount4 = -fadeAmount4;
}
// reverse the direction of the fading at the ends of the fade:
if (brightness4 <= 0 || brightness4 >= 250) {
fadeAmount4 = -fadeAmount4;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
//Blinking white LED randomizer
digitalWrite(led3, !digitalRead(led3)); // turn the LED on/off
randNumber = random(15, 25);
//wait for randomizer
delay(random(20,20));
} }
PLEASE HELP LOL