The real engineer
LEGO Spike Essentials kit
I have grown up with the Hello Crazies of science asylum and the What If of Vsauce. Time moves forward and around the age of 15, I have a few papers telling what I then thought was a scientific script!
Study felt fun! 9 hours straight didn't present a problem and there was no need for a disparate fight with the books to learn something new...why were exams nerve racking then?
Mark Rober, Sal Khan, Derek Muller, and a few dearest teachers and friends taught me that the world makes sense, unlike most of the classroom rant.
I found answers to my most existential questions in learning. From what on Earth I can do to a genocide through what my role is towards homeless people I meet everyday to what I owe my family and friends and how to counteract root problems of our society: decent education.
That is what I am hoping to get one step closer to through this project.
"Create an engaging, low-cost home-lab where parents and children can have fun experimenting and learning."
For easier track of successful features
For easier assembly and view control
Front face with projected geometry from electronics
Base with projected holes of Arduino
Side with reset button
Side with opennings of Arduino
Cutting parameters on the laser cutter on a 3 mm plywood sheet
Adding and nesting all parts
Illustration of inputs and outputs
Connect the power with a battery or an adaptor (9V)
Move the joystick down to pick a challenge then press
Keep pressing down to view the steps
Press the button to increment your score
Press the switch mode button to view the electricity lab features
Put the object you want to test its conductivity on the sensor
Use the voltmeter terminals to calculate voltage difference
Reset the system to start over!
Component
Price (LE)
Link
--> Touch sensor
--> 20
--> Reset switch
--> 10
I used a 9-volt adaptor to provide adequate voltage for the Arduino and the many components included
It can be replaced with a 7+ to 12 Volt battery through the same socket
Include libraries and define variables
Organise buzzer tones in a list
Setting the menu navigation and levels
Volt sensor variables setup
Setting Arduino pins connections
Preparing content blocks
Function handling the touch sensor
Function handling the volt sensor
Controlling the LCD with the joystick
Displaying the main menu
Update the LCD reading based on the position of the joystick
Updating the 7segment
Setting the pinmodes of pins
Controlling different levels of lists based on the joystick press
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4); // change address if needed
int i = 0;
//scroll logic
int level = 0;
int arrow = 0;
int buzzerbutton = 12;
//end of scroll logic
// Variables for navigation
int currentIndexMainMenu = 0;
const int listSizeMainMenu = 7;
String mainMenuList[listSizeMainMenu] = {"Challenge 1", "Challenge 2", "Challenge 3", "Challenge 4", "Challenge 5", "", ""};
// end of variables for navigation
//volt sensor setup
int voltInput = A3;
float vout = 0.0;
float vin = 0.0;
float R1 = 30000.0; //
float R2 = 7500.0; //
int voltvalue = 0;
//end of volt sensor setup
int modeSwitch = 9;
//Joystick code
int JoyStick_X = A0; // X-axis-signal
int JoyStick_Y = A1; // Y-axis-signal
int selectButton = 10;
//End of Joystick code
//touch sensor setup
int touchSensor = 11;
//end of touch sensor setup
////////////////////////////////////////////////
///////////////////////////////////////////////
//////////////////////////////////////////////
//FUNCTIONS
////////////////////////////////////////////
///////////////////////////////////////////
//MODE 1
void touch() {
lcd.setCursor(0, 0);
lcd.print("The object is a ");
lcd.setCursor(0, 1);
if (digitalRead(touchSensor) == 1) {
lcd.print("conductor! ");
} else {
lcd.print("non-conductor!");
}
delay(500);
}
void volt() {
voltvalue = analogRead(voltInput);
vout = (voltvalue * 5.0) / 1024.0; // see text
vin = vout / (R2 / (R1 + R2));
lcd.setCursor(0, 2);
lcd.print("INPUT V= ");
lcd.setCursor(0, 3);
lcd.println(vin, 2);
}
//END OF MODE 1
////////////////////////////////////////////////
///////////////////////////////////////////////
//////////////////////////////////////////////
//FUNCTIONS
////////////////////////////////////////////
///////////////////////////////////////////
//MODE 2
//Challenges script
const int listSizec1 = 3;
String c1[listSizec1] = {"c1 step 1", "c1 step 2", "c1 step 3"};
const int listSizec2 = 3;
String c2[listSizec2] = {"c2 step 1", "c2 step 2", "c2 step 3"};
const int listSizec3 = 3;
String c3[listSizec3] = {"c3 step 1", "c3 step 2", "c3 step 3"};
const int listSizec4 = 3;
String c4[listSizec4] = {"c4 step 1", "c4 step 2", "c4 step 3"};
const int listSizec5 = 3;
String c5[listSizec5] = {"c5 step 1", "c5 step 2", "c5 step 3"};
//End of challenges script
void lcd_main_menu() {
if (analogRead(JoyStick_X) > 2 && analogRead(JoyStick_Y) < 2) {
currentIndexMainMenu++;
if (currentIndexMainMenu + 2 >= listSizeMainMenu) currentIndexMainMenu = 0;
displayItemMainMenu();
delay(200);
}
}
///////////////////////////////
void C1() {
lcd.clear();
lcd.setCursor(0, 0);
level = 2;
lcd.print("Welcome to Game 1!");
lcd.setCursor(0, 1);
lcd.print("Move down to see the steps...");
}
void C1Steps() {
//while (analogRead(JoyStick_X) > 2 && analogRead(JoyStick_Y) < 2 == 1) {}
for (int i = 0; i < listSizec1; i = i) {
if (analogRead(JoyStick_X) > 2 && analogRead(JoyStick_Y) < 2) {
delay(200);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step number ");
lcd.print(i + 1);
lcd.print(": ");
lcd.setCursor(0, 1);
lcd.print(c1[i]);
i++;
}
}
}
///////////////////////////////////////
void C2() {
lcd.clear();
lcd.setCursor(0, 0);
level = 2;
lcd.print("Welcome to Game 2!");
lcd.setCursor(0, 1);
lcd.print("Move down to see the steps...");
}
void C2Steps() {
//while (analogRead(JoyStick_X) > 2 && analogRead(JoyStick_Y) < 2 == 1) {}
for (int i = 0; i < listSizec2; i = i) {
if (analogRead(JoyStick_X) > 2 && analogRead(JoyStick_Y) < 2) {
delay(200);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step number ");
lcd.print(i + 1);
lcd.print(": ");
lcd.setCursor(0, 1);
lcd.print(c2[i]);
i++;
}
}
}
//////////////////////////////////////
void C3() {
lcd.clear();
lcd.setCursor(0, 0);
level = 2;
lcd.print("Welcome to Game 3!");
lcd.setCursor(0, 1);
lcd.print("Move down to start...");
}
void C3Steps() {
// while (analogRead(JoyStick_X) > 2 && analogRead(JoyStick_Y) < 2 == 1) {}
for (int i = 0; i < listSizec3; i = i) {
if (analogRead(JoyStick_X) > 2 && analogRead(JoyStick_Y) < 2) {
delay(200);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step number ");
lcd.print(i + 1);
lcd.print(": ");
lcd.setCursor(0, 1);
lcd.print(c3[i]);
i++;
}
}
}
////////////////////////////////
void C4() {
lcd.clear();
lcd.setCursor(0, 0);
level = 2;
lcd.print("Welcome to Game 4!");
lcd.setCursor(0, 1);
lcd.print("Move down to see the steps...");
}
void C4Steps() {
//while (analogRead(JoyStick_X) > 2 && analogRead(JoyStick_Y) < 2 == 1) {}
for (int i = 0; i < listSizec4; i = i) {
if (analogRead(JoyStick_X) > 2 && analogRead(JoyStick_Y) < 2) {
delay(200);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step number ");
lcd.print(i + 1);
lcd.print(": ");
lcd.setCursor(0, 1);
lcd.print(c4[i]);
i++;
}
}
}
/////////////////////////////
void C5() {
lcd.clear();
lcd.setCursor(0, 0);
level = 2;
lcd.print("Welcome to Game 5!");
lcd.setCursor(0, 1);
lcd.print("Move down to see the steps...");
}
void C5Steps() {
// while (analogRead(JoyStick_X) > 2 && analogRead(JoyStick_Y) < 2 == 1) {}
for (int i = 0; i < listSizec5; i = i) {
if (analogRead(JoyStick_X) > 2 && analogRead(JoyStick_Y) < 2) {
delay(200);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step number ");
lcd.print(i + 1);
lcd.print(": ");
lcd.setCursor(0, 1);
lcd.print(c5[i]);
i++;
}
}
}
void displayItemMainMenu() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Select:");
lcd.setCursor(0, 1);
lcd.print(">");
arrow = currentIndexMainMenu + 1;
// arrow = currentIndexMainMenu +1 ; confirm that the arrow caries the right value
lcd.print(mainMenuList[currentIndexMainMenu]);
//lcd.print(arrow);
lcd.setCursor(0, 2);
lcd.print(mainMenuList[currentIndexMainMenu + 1]);
lcd.setCursor(0, 3);
lcd.print(mainMenuList[currentIndexMainMenu + 2]);
}
/////////////score function
void score (){
delay(500);
i += 1;
tone(13, 165, 1000); // play tone 40 (E3 = 165 Hz)
delay(250); // Wait for 250 millisecond(s)
tone(13, 294, 1000); // play tone 50 (D4 = 294 Hz)
delay(250); // Wait for 250 millisecond(s)
tone(13, 932, 1000); // play tone 70 (A#5 = 932 Hz)
delay(500); // Wait for 500 millisecond(s)
noTone(13);
delay(1000); // Wait for 1000 millisecond(s)
if (i == 9) {
// Turning on NINE
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
digitalWrite(4, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
digitalWrite(8, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
i=0;
} else {
if (i == 8) {
// Turning on EIGHT
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(8, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
} else {
if (i == 7) {
// Turning on SEVEN
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(7, LOW);
digitalWrite(4, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(8, LOW);
delay(1000); // Wait for 1000 millisecond(s)
} else {
if (i == 6) {
// Turning on SIX
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(7, HIGH);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(8, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
} else {
if (i == 5) {
// Turning on FIVE
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(7, HIGH);
digitalWrite(4, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
digitalWrite(8, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
} else {
if (i == 4) {
// Turning on FOUR
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
digitalWrite(4, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(8, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
} else {
if (i == 3) {
// Turning on THREE
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(7, LOW);
digitalWrite(4, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
digitalWrite(8, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
} else {
if (i == 2) {
// Turning on TWO
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(7, LOW);
digitalWrite(4, LOW);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(8, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
} else {
if (i == 1) {
// Turning on ONE
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(7, LOW);
digitalWrite(4, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(8, LOW);
} else {
// Turning on ZERO
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(8, LOW);
}
}
}
}
}
}
}
}
}
}
/////////////end of score function
void setup() {
//////////////////SCORE
pinMode(buzzerbutton, INPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(7, OUTPUT);
pinMode(4, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(8, OUTPUT);
pinMode(12, INPUT);
pinMode(13, OUTPUT);
///////////////////////end of score
//mode 1 setup
pinMode(touchSensor, INPUT);
pinMode(voltInput, INPUT);
lcd.init();
lcd.backlight();
//end of mode 1 setup
//mode 2
pinMode(selectButton, INPUT);
digitalWrite(selectButton, HIGH);
// Display the first item
if (digitalRead(modeSwitch) == 0) {
displayItemMainMenu();
}
//end of mode 2
pinMode(modeSwitch, INPUT_PULLUP);
}
void loop() {
if (digitalRead(buzzerbutton) == HIGH){
score();
}
if (digitalRead(modeSwitch) == 1) {
//mode 1
touch();
volt();
}
//end of mode 1
else { //entire second mode
if (digitalRead(selectButton) == 0) {
level = 1;
}
if (level == 0) {
lcd_main_menu();
}
//c1 check
if (level == 1 && arrow == 1) {
C1();
} else if (level == 2 && arrow == 1) {
C1Steps();
}
//c2 check
if (level == 1 && arrow == 2) {
C2();
} else if (level == 2 && arrow == 2) {
C2Steps();
}
//c3 check
if (level == 1 && arrow == 3) {
C3();
} else if (level == 2 && arrow == 3) {
C3Steps();
}
//c4 check
if (level == 1 && arrow == 4) {
C4();
} else if (level == 2 && arrow == 4) {
C4Steps();
}
//c5 check
if (level == 1 && arrow == 5) {
C5();
} else if (level == 2 && arrow == 5) {
C5Steps();
}
}
}
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
// ====== Score Variables ======
int i = 0; // score
int buzzerbutton = 12;
bool playingMelody = false;
unsigned long lastToneTime = 0;
int melodyStep = 0;
float x,y;
struct ToneStep {
int frequency;
int duration;
};
ToneStep melody[] = {
{165, 200}, // E3
{294, 200}, // D4
{932, 500} // A#5
};
const int melodyLength =
sizeof(melody) / sizeof(melody[0]);
// ====== Debounce Variables ======
unsigned long lastButtonPress = 0;
const unsigned long debounceDelay = 200; // ms
// ====== Menu Navigation ======
int level = 0;
int arrow = 0;
int currentIndexMainMenu = 0;
const int listSizeMainMenu = 7;
String mainMenuList[listSizeMainMenu] = {
"Challenge 1", "Challenge 2", "Challenge 3",
"Challenge 4", "Challenge 5", "", ""
};
// ====== Volt Sensor Setup ======
int voltInput = A3;
float vout = 0.0;
float vin = 0.0;
float R1 = 30000.0;
float R2 = 7500.0;
int voltvalue = 0;
// ====== Mode Switch ======
int modeSwitch = 9;
// ====== Joystick ======
int JoyStick_X = A0;
int JoyStick_Y = A1;
int selectButton = 10;
// ====== Touch Sensor ======
int touchSensor = 11;
// ====== Challenge Steps ======
const int listSizec1 = 3;
String c1[listSizec1] = {"c1 step 1", "c1 step 2", "c1 step 3"};
const int listSizec2 = 3;
String c2[listSizec2] = {"c2 step 1", "c2 step 2", "c2 step 3"};
const int listSizec3 = 3;
String c3[listSizec3] = {"c3 step 1", "c3 step 2", "c3 step 3"};
const int listSizec4 = 3;
String c4[listSizec4] = {"c4 step 1", "c4 step 2", "c4 step 3"};
const int listSizec5 = 3;
String c5[listSizec5] = {"c5 step 1", "c5 step 2", "c5 step 3"};
// ====== Function Prototypes ======
void updateSevenSegment(int num);
void displayItemMainMenu();
// =====================================================
// MODE 1 FUNCTIONS
// =====================================================
void touch() {
lcd.setCursor(0, 0);
lcd.print("The object is a ");
lcd.setCursor(0, 1);
if (digitalRead(touchSensor) == 1) {
lcd.print("conductor! ");
} else {
lcd.print("non-conductor!");
}
}
void volt() {
voltvalue = analogRead(voltInput);
vout = (voltvalue * 5.0) / 1024.0;
vin = vout / (R2 / (R1 + R2));
lcd.setCursor(0, 2);
lcd.print("INPUT V= ");
lcd.setCursor(0, 3);
lcd.print(vin, 2);
}
// =====================================================
// MODE 2 FUNCTIONS (Challenges)
// =====================================================
void lcd_main_menu() {
static unsigned long lastNav = 0;
if (millis() - lastNav > 250) { // joystick debounce
x = analogRead (JoyStick_X) * (5.0 / 1023.0);
y = analogRead (JoyStick_Y) * (5.0 / 1023.0);
if (x > 4 && y > 2) {
currentIndexMainMenu++;
if (currentIndexMainMenu + 2 >= listSizeMainMenu) currentIndexMainMenu = 0;
displayItemMainMenu();
lastNav = millis();
}
}
}
void displayItemMainMenu() {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Select:");
lcd.setCursor(0, 1);
lcd.print(">");
arrow = currentIndexMainMenu + 1;
lcd.print(mainMenuList[currentIndexMainMenu]);
lcd.setCursor(0, 2);
lcd.print(mainMenuList[currentIndexMainMenu + 1]);
lcd.setCursor(0, 3);
lcd.print(mainMenuList[currentIndexMainMenu + 2]);
}
void showChallengeIntro(String title) {
lcd.clear();
lcd.setCursor(0, 0);
level = 2;
lcd.print("Welcome to " + title);
lcd.setCursor(0, 1);
lcd.print("Move down to see steps");
}
void showChallengeSteps(String steps[], int size) {
static int idx = 0;
static unsigned long lastStep = 0;
if (millis() - lastStep > 250) { // debounce
x = analogRead (JoyStick_X) * (5.0 / 1023.0);
y = analogRead (JoyStick_Y) * (5.0 / 1023.0);
if (x > 4 && y > 2) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Step ");
lcd.print(idx + 1);
lcd.setCursor(0, 1);
lcd.print(steps[idx]);
idx++;
if (idx >= size) idx = 0;
lastStep = millis();
}
}
}
// =====================================================
// SCORE FUNCTIONS
// =====================================================
void startScore() {
if (!playingMelody) {
i++;
if (i > 9) i = 0; // wrap around after 9
updateSevenSegment(i); // update 7-segment immediately
playingMelody = true;
melodyStep = 0;
lastToneTime = millis();
tone(13, melody[melodyStep].frequency, melody[melodyStep].duration);
}
}
void handleScore() {
if (playingMelody) {
if (millis() - lastToneTime >= (unsigned long)melody[melodyStep].duration + 50) {
melodyStep++;
if (melodyStep < melodyLength) {
lastToneTime = millis();
tone(13, melody[melodyStep].frequency, melody[melodyStep].duration);
} else {
noTone(13);
playingMelody = false;
}
}
}
}
void updateSevenSegment(int num) {
switch (num) {
case 0: digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(7,HIGH); digitalWrite(4,HIGH); digitalWrite(6,HIGH); digitalWrite(5,HIGH); digitalWrite(8,LOW); break;
case 1: digitalWrite(2,LOW); digitalWrite(3,HIGH); digitalWrite(7,LOW); digitalWrite(4,HIGH); digitalWrite(6,LOW); digitalWrite(5,LOW); digitalWrite(8,LOW); break;
case 2: digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(7,LOW); digitalWrite(4,LOW); digitalWrite(6,HIGH); digitalWrite(5,HIGH); digitalWrite(8,HIGH); break;
case 3: digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(7,LOW); digitalWrite(4,HIGH); digitalWrite(6,LOW); digitalWrite(5,HIGH); digitalWrite(8,HIGH); break;
case 4: digitalWrite(2,LOW); digitalWrite(3,HIGH); digitalWrite(7,HIGH); digitalWrite(4,HIGH); digitalWrite(6,LOW); digitalWrite(5,LOW); digitalWrite(8,HIGH); break;
case 5: digitalWrite(2,HIGH); digitalWrite(3,LOW); digitalWrite(7,HIGH); digitalWrite(4,HIGH); digitalWrite(6,LOW); digitalWrite(5,HIGH); digitalWrite(8,HIGH); break;
case 6: digitalWrite(2,HIGH); digitalWrite(3,LOW); digitalWrite(7,HIGH); digitalWrite(4,HIGH); digitalWrite(6,HIGH); digitalWrite(5,HIGH); digitalWrite(8,HIGH); break;
case 7: digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(7,LOW); digitalWrite(4,HIGH); digitalWrite(6,LOW); digitalWrite(5,LOW); digitalWrite(8,LOW); break;
case 8: digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(7,HIGH); digitalWrite(4,HIGH); digitalWrite(6,HIGH); digitalWrite(5,HIGH); digitalWrite(8,HIGH); break;
case 9: digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(7,HIGH); digitalWrite(4,HIGH); digitalWrite(6,LOW); digitalWrite(5,HIGH); digitalWrite(8,HIGH); break;
}
}
// =====================================================
// SETUP
// =====================================================
void setup() {
// score pins
pinMode(buzzerbutton, INPUT_PULLUP);
pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(7, OUTPUT);
pinMode(4, OUTPUT); pinMode(6, OUTPUT); pinMode(5, OUTPUT); pinMode(8, OUTPUT);
pinMode(13, OUTPUT);
// mode 1
pinMode(touchSensor, INPUT);
pinMode(voltInput, INPUT);
lcd.init();
lcd.backlight();
// mode 2
pinMode(selectButton, INPUT_PULLUP);
pinMode(modeSwitch, INPUT_PULLUP);
displayItemMainMenu();
}
// =====================================================
// LOOP
// =====================================================
void loop() {
// ====== Handle Score Button with Debounce ======
static bool lastBuzzerState = LOW;
bool buzzerState = digitalRead(buzzerbutton);
if (buzzerState == LOW && lastBuzzerState == LOW && millis() - lastButtonPress > debounceDelay) {
startScore();
lastButtonPress = millis();
}
lastBuzzerState = buzzerState;
handleScore();
// ====== Mode Handling ======
if (digitalRead(modeSwitch) == HIGH) {
// Mode 1: Sensors
touch();
volt();
} else {
// Mode 2: Challenges
if (digitalRead(selectButton) == LOW) {
level = 1;
}
if (level == 0) lcd_main_menu();
if (level == 1 && arrow == 1) showChallengeIntro("Game 1");
else if (level == 2 && arrow == 1) showChallengeSteps(c1, listSizec1);
if (level == 1 && arrow == 2) showChallengeIntro("Game 2");
else if (level == 2 && arrow == 2) showChallengeSteps(c2, listSizec2);
if (level == 1 && arrow == 3) showChallengeIntro("Game 3");
else if (level == 2 && arrow == 3) showChallengeSteps(c3, listSizec3);
if (level == 1 && arrow == 4) showChallengeIntro("Game 4");
else if (level == 2 && arrow == 4) showChallengeSteps(c4, listSizec4);
if (level == 1 && arrow == 5) showChallengeIntro("Game 5");
else if (level == 2 && arrow == 5) showChallengeSteps(c5, listSizec5);
}
}
Prompt used: change the logic to millis instead of delay and account for debounce, show me the entire code after modification and embedding these modifications
Changes made: delay logic changes to millis() instead of delay and switch cases instead of nested if
The millis() logic is a simple subtraction of current time and the time the action started, this time difference provides the same effect of a delay without stopping the Arduino from multitasking
The switch case is much more organised and compact than nested if conditions
When dealing with buttons, delays are necessary to avoid debounce and logic failure due to noise
Tested each component separately with its test code
Gently fixed components on the front face
Used yellow tape to group wires of the same component
Connected each wire to its place on the Arduino
Had to do some aerobics to fix tricky components
Closing the yummy sandwich
Fixing electronics was really challenging, our instructor Ahmed explained to me how to create the wooden fixture used above in the 7-segement
The "done button" was sensing a lot of noise, Menna explained that this was because the circuit has many components, she advised to isolate the wires. From what we learned in the assignments as well I tried pulling up the button in the code and it worked!
The fix holes of the Arduino were shifted, Tarek showed us how to use the drill to make minor modifications. Tip: don't fully depend on imported electronics to take measurement, use a caliper to verify
Enhance the appearance of the enclosure (colors and engravings)
Use a graphical lcd for a better visual explanation of the challenges steps
Expand the lab with a lego-like kit to enable building and messing around with mechanics