This Image is a representation of the circuit I am supposed to build for a project for school. However, I have little to no knowledge over how to use circuits, build them, etc. All I have so far is a code for the Arduino UNO that seems shaky at best (it works in the simulation, but I don't know if it also works IRL?) and I would really, really appreciate some help.
If anyone is knowledgeable in this field, please, do respond to this thread. The main things I'm confused about is what components would we actually need? I've made a basic list so far, yet there are topics such as capacitors etc. which just confuse me more. All I would need to know are what components I would need to fully make this a functioning circuit, as well as maybe some hints as to if my code would truly work IRL.
The following is the code:
int LEDR=11;
int pir=2;
int buzzer=5;
int r=11;
void setup()
{
pinMode(pir,INPUT);
pinMode(LEDR,OUTPUT);
pinMode(buzzer,OUTPUT);
}
void loop()
{
int val= digitalRead(pir);
Serial.println(val);
if(val==HIGH){
digitalWrite(LEDR,r);
}
if (val==HIGH){
digitalWrite(buzzer,HIGH);
}
else{
digitalWrite(LEDR,LOW);
digitalWrite(buzzer,LOW);
}
delay(10);
}
Please do let me know if this would work. Any help would be much appreciated. Thank you to anyone who takes the time to respond in advance.
They asked you to build an electronic circuit knowing that you know nothing about electronics.
What kind of school is this?
Why don't you ask your teachers for help?
I don't know, this was my first go at coding something and all I did was mix and match the codes form different circuits on Tinkercad till something fit, and I called it a day due to the due date being ridiculously close to when we got the assignment assgned.
The testing thing is, again, difficult to do as the due date for the documentation is tomorrow. I am supposed to provide date like which currents and which voltage certain components will be provided with, yet I can't do that in my current circumstances. The teacher really knows how to make life hard😭
I would truly love to do that, however the time our teacher gave us for this project, specifically the assignment I'm currently working on, is extremely short. I don't think it'd be possible for me to gain a basic understanding of coding and electronics, and then also be able to submit my assignment till tomorrow.
Reformatting your code (CTRL-T in the IDE) makes it easier to see structure:
int LEDR = 11;
int pir = 2;
int buzzer = 5;
int r = 11;
void setup()
{
pinMode(pir, INPUT);
pinMode(LEDR, OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop()
{
int val = digitalRead(pir);
Serial.println(val);
if (val == HIGH) {
digitalWrite(LEDR, r);
}
if (val == HIGH) {
digitalWrite(buzzer, HIGH);
}
else {
digitalWrite(LEDR, LOW);
digitalWrite(buzzer, LOW);
}
delay(10);
}
The things that look weird to me is missing a Serial.begin(115200); in setup and the use of "r".
I'd use a Serial.print(val); instead of a println() to make the diagnosing less frantic, but if the pir is wired up right, you should see useful diagnostics on the serial monitor.
If you are confused, then you can test each part in the setup() function.
Let the led blink, make the buzzer buzz, and show something on the Serial Monitor.
Here is my own interpretation in the Wokwi simulator:
I apologize for my lack on knowledge and I know this is probably annoying, but what is a serial monitor?
If it has something to do with code, I've made my entire code in Tinkercad so I'm not really too sure about what it means. Thank you, though, I'll replace this piece of code with the original one.
I'm sorry if I phrased my post weirdly, I'm in a hurry and I didn't get the chance to critically go over the phrasing. I basically would like to know what components I would need to build the project because looking on the internet just confused me more because what I saw did not correlate yet apparently somehow had something to do with my project.