#include <Adafruit_SSD1306.h>
#include <Servo.h>
#include <avr/pgmspace.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
Adafruit_SSD1306 oled(128,64,&Wire,-1);
Servo rightServo;
int brainHighlight = 0;
int redPin = 3;
int bluePin = 6;
int greenPin = 5;
const char string_0[] PROGMEM = "The Frontal Lobe is responsible for controlling the way you think, how you move, how you remember things, and how you interact withothers."; // "String 0" etc are strings to store - change to suit.
const char string_1[] PROGMEM = "The Cerebral Cortex is important for memory, thinking, learning, reasoning, problem-solving, emotions, and consciousness.";
const char string_2[] PROGMEM = "The Corpus Callosum allows information totransfer from one side of the brain to the other, and plays a key role in movement control of the body.";
const char string_3[] PROGMEM = "The Occipital Lobe isimportant for processing distance, depth, perception, color determination, object and face recognition, and formation of memory.";
const char string_4[] PROGMEM = "The Parietal Lobe is responsible for processing touch, pressure, heat, cold,and pain.";
const char string_5[] PROGMEM = "The Pons handles a person's sleep/wake schedule and breathing. The Pons produce dopamine and acetylcholine.";
const char string_6[] PROGMEM = "The Cerebellum is responsible for movement and balance.It is also a vital part of language, attention, and eye movement.";
const char string_7[] PROGMEM = "The Pituitary Gland is the master gland, which controls sexualdevelopment, growth, and regulates other hormones.";
const char string_8[] PROGMEM = "The Hypothalamus is the smart control center, which is responsible for keeping the body in homeostasis.";
const char string_9[] PROGMEM = "The Medulla Oblongatamanages the heart, breathing, and circulation throughout the body.";
const char string_10[] PROGMEM = "The Thalamus is the relay station. All senses (except smell)must pass through here for interpretation.";
const char string_11[] PROGMEM = "The Spinal Cord sendsmotor commands from the brain to the body, sends sensory information to the brain, and coordinates reflexes.";
const char *const string_table[] PROGMEM = {string_0, string_1, string_2, string_3, string_4, string_5, string_6, string_7, string_8, string_9, string_10, string_11};
char buffer[256]; // make sure this is large enough for the largest string it must hold
void setup(){
Serial.begin(9600);
pinMode(redPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(7,INPUT_PULLUP);
rightServo.write(90);
rightServo.attach(11);
if(!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
}
void loop(){
oled.clearDisplay();
oled.setTextSize(1);
oled.setTextColor(WHITE);
oled.setCursor(1,0);
if(brainHighlight < 11 && digitalRead(7) == LOW){
strcpy_P(buffer, (char *)pgm_read_ptr(&(string_table[brainHighlight])));
oled.println(buffer);
oled.display();
brainHighlight = brainHighlight + 1;
}else if(brainHighlight == 11 && digitalRead(7) == LOW){
strcpy_P(buffer, (char *)pgm_read_ptr(&(string_table[brainHighlight])));
oled.println(buffer);
oled.display();
brainHighlight = 0;
}
delay(250);
}
void setColor(int redValue, int greenValue, int blueValue) {
analogWrite(redPin, redValue);
analogWrite(greenPin, greenValue);
analogWrite(bluePin, blueValue);
}