Need guidance for a work project (very beginner)

Hi everyone! I’m new here, and I’m new with Arduino as well. My work project consists on blinking all LEDs with the minimum of clicks possible.
I have a picture attached a picture which shows the circuit. It’s in portuguese but I’ll translate it:
“pressButton - door 12 - which serves as reset
pressButton - door 11 - which chooses/hits the LED that’s on
9 LEDs that are on to win the game”

And this is what needs to happen:

"1.Turn on the LEDs in a sequence. The program starts by turning on the LED during a certain period of time (which can be 1/2 a second, 1 second or another period of time - time_transition_led). If the LED hasn’t been discovered, it should turn off and turn on the next one. If the LED has been discovered, the same stays on, as the program continues to turn on the LEDs one after another. This sequence is related to the connection between the doors, the first LED is connected to door 2, the second to door 3 etc.

2.Reset. The reset button (door 12) turns off all LEDs already discovered and restarts the sequence of turning on the LEDs. That means, after the reset, all LEDs are turned off and have to restart on the first LED (door 2) as well as the number of clicks already given.

3.Discovery. The button of choosing/hitting the LED makes it possible to hit on the LED. The discovery is done when a LED is turned on and there’s a click by the time it’s turned on. For example, if LED 3 is turned on and on that moment the button is pressed, LED 3 needs to stay turned on, as it was discovered. The number of clicks needs to step up when the button is pressed.

4.Victory. The functionnality of victory makes all discovered LEDs blink for 20 seconds. After that, all LEDs are turned off and the game restarts. During the presentation of the victory, we need to display the number of clicks given to discover the LEDs, in the serial monitor."

Here’s a link that shows how it should look like: https://youtu.be/cPdIIFBJHDo

I would like to ask your help to know how I can write my code to make this happen. I have 0 experience programming and working with Arduino, and I also have to do this on Tinkercard. What I’m really asking is not to give me the full code, but rather to help me understand what kind of code I could write and explain me what it’s going to do, give me some lights on how to make it happen. It’s the best way for me to learn at this point :slight_smile:

Thanks a lot if you have the patience to help me out!

I’m confused .. isn’t Tinkerca(r)d a 3D design package and nothing to do with coding. This looks like a college type project looking at the attached typed up picture . What’s the background , who has asked you to do what, and what’s your experience ( you suggest zero)? People are willing to help but not shortcut course work type questions, which doesn’t help your education . Anyhow... You really need to do some coding with an Arduino before starting something like this , as a started your project can be put into a series of logical statement .. IF...THEN ... ELSE ..

hammy:
I’m confused … isn’t Tinkerca(r)d a 3D design package and nothing to do with coding.
This looks like a college type project looking at the attached typed up picture . What’s the background , who has asked you to do what, and what’s your experience ( you suggest zero)?
People are willing to help but not shortcut course work type questions, which doesn’t help your education .
Anyhow…
You really need to do some coding with an Arduino before starting something like this , as a started your project can be put into a series of logical statement … IF…THEN … ELSE …

You can build circuits on tinkercad, then code for the circuit you built.

It’s a quick project for a computer engineering course. Our teacher asked us. My experience is close to 0, but I’m learning some things as I’m trying to do it.

And I agree with you, I’m not looking for someone to make this project for me, but rather understand what I can do it make this work, what kind of coding I could be using and stuff like that. I’m willing to learn and I want to do this on my own, but I need some help to understand how this works and what kind of codes I could write. I’m seeing a bunch of tutorials online and I’m getting to the logic of it but it’s not enough, that’s why I came here.

I also don’t have time to practice with easier projects (for lots of personnal reasons), so this needs to be my first project and the first time I work with something like this. With that said, I’m quick and interested in learning everything :slight_smile:

Without learning some basic coding experience, this is too difficult/impossible as a first project, and incompatible with your tutors request . Go see him for clarification. You can’t code without learning how to code ( you can’t run without learning to crawl, then walk) maybe he just wants the logical arguments laid out as a table ???? Again seek advice .

My last paragraph gave you some pointers .

sqalx95: I have 0 experience programming and working with Arduino, and I also have to do this on Tinkercard.

Does that mean you have to learn Tinkercad as well as Arduino programming? - that's a very big ask.

...R

Robin2:
Does that mean you have to learn Tinkercad as well as Arduino programming? - that’s a very big ask.

…R

Not necessarily, the circuit is already built, I just need to program it like I do in Arduino.

So, I went my way to find out and to learn everything I could at this point.
This the code I have at this moment:


int delay_led=500;
int pinreset=12;
int pinhit=11;
int estadobotao;
int estadoanteriorbotao;
int x;

void setup()
{
Serial.begin(9600);
for(x = 2; x <= 10; x = x+1){
pinMode(x, OUTPUT);
}
pinMode(pinreset, INPUT_PULLUP);
pinMode(pinhit, INPUT_PULLUP);
}

void loop()
{
for (x = 2; x<= 10; x = x+1){
digitalWrite(x, HIGH);
delay(delay_led);
digitalWrite(x, LOW);
delay(delay_led);
if
digitalRead(pinhit == true);
digitalWrite(x, LOW);
}
}
}

This is to make all LEDs blink, one by one.
“estadodobotao” and “estadoanteriorbotao” are the state of the button and the state before the actual state (when you press him and before you press him).

Now, I have to find how to insert the reset button, hit button, how to put in code that when you press the button and it discovers the one that’s blinking it turns it on, and so on.

A friend helped me with some codes I can make use of to make all of that happen:


long time_before;
long delay_led = 500;
int pinreset=12;
int pinhit = 11;
bool led_discovered = false;

void setup() {
Serial.begin(9600);

pinMode(13, OUTPUT); //this is just an example for one led
pinMode(pinhit, INPUT_PULLUP);

time_before = 0;
}

bool state_before_pinhit = false;
void loop() {
if(millis() - time_before >= delay_led) {
if(digitalRead(13) == HIGH) {
if(led_discovered == false) {
digitalWrite(13, LOW);
}
} else {
digitalWrite(13, HIGH);
}
time_before = millis();
}
bool actual_state_pinhit = !digitalRead(pinhit);
if(state_before_pinhit != actual_state_pinhit) {
if(actual_state_pinhit == HIGH) {
Serial.println(“Clicked”);
if(digitalRead(13) == HIGH) {
led_discovered = true;
Serial.println(“Led discovered”);
}
}
state_before_pinhit = actual_state_pinhit;
}
}


I can understand more or less the logic of this code that serves as a base, but I have trouble understanding the millis() and to make it work with the rest of the code, while also making it work with all the leds.

It might be useful to follow this thread. Reads like a classmate of yours.

https://forum.arduino.cc/index.php?topic=643646.0

dougp:
It might be useful to follow this thread. Reads like a classmate of yours.

https://forum.arduino.cc/index.php?topic=643646.0

I was going to reply that there are arrays in sqalx95’s future, but I see that’s already the consensus in the other student’s thread :wink:

(Wonder if the teacher is monitoring the forum? I would be, if I were he or she. In fact I’d be throwing suggestions out into the forum to see if they come back in my students’ code . )

sqalx95:
I also don’t have time to practice with easier projects (for lots of personnal reasons)

That’s very unlikely to work. Time invested to learn the building blocks will actually make the overall development time shorter. Whenever I write a sketch that needs a technique or a bit of hardware I have little or no experience with, I write a “baby” sketch to get that thing working by itself. Then it’s (reasonably) simple to move that coding into the main sketch, knowing that the new stuff is actually sound. If you throw 2-3 new techniques into the main sketch without testing each on their own, when it doesn’t work then you have no easy way to diagnose the problem since you can’t trust any of the pieces, let alone try to understand the interactions among them.

Tinkercad can be used to model the physical shapes of boards and components. I don't think it helps you design circuits or model their electrical behaviour.

It provides some ready made shapes like a UNO, RPi. You can make your own.

It is helpful for designing a housing for your project.

John.

A Tinkercad arrangement of some components including a UNO & a RPi.

Capture.PNG

And that useless battery!