0% found this document useful (0 votes)
244 views

2-Basic Arduino Uno Prototyping Using WOKWI

Uploaded by

Genemark Cano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
244 views

2-Basic Arduino Uno Prototyping Using WOKWI

Uploaded by

Genemark Cano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Basic Arduino Uno Prototyping using WOKWI

INTRODUCTION

In this activity, you will use the WOKWI Arduino simulator to create a project involving
three LEDs (red, yellow, blue) and a push button. The objective is to program the Arduino Uno
to cycle through three distinct LED patterns (running, blinking, and staying on) each time the
button is pressed. This hands-on project is designed to enhance your understanding of Arduino
programming, LED control, and basic circuit building in a simulated environment.

To help you get started with the concepts and tools required, I recommend watching the
following tutorial videos. These videos will guide you through setting up your WOKWI
environment and working with Arduino components:
1. Introduction to WOKWI Arduino Simulator
The Best Robotics Enterprise - Video 1: Introduction
Learn the basics of using WOKWI for Arduino simulation and how to navigate the
platform.
2. Understanding Push Buttons in Arduino
The Best Robotics Enterprise - Video 2: Push Button Tutorial
This video explains how push buttons work in Arduino projects and demonstrates how to
integrate them into your circuits.
3. LED Control and Programming
The Best Robotics Enterprise - Video 3: LED Control with Arduino
Understand how to control multiple LEDs using Arduino, and apply this knowledge to
your project.

INSTRUCTIONS
Step 1: Access WOKWI
1. Open Your Web Browser:
o Launch your preferred web browser (e.g., Chrome, Firefox, Edge).
2. Navigate to WOKWI:
o Go to the WOKWI Arduino simulator by entering the following URL in the address
bar: https://wokwi.com/

o or by clicking the links:


Wokwi - World's most advanced ESP32 Simulator

Step 2: Sign Up or Sign In


1. Locate the Sign-Up/Sign-In Button:
o On the top-right corner of the WOKWI homepage, click on the "Sign Up" or
"Sign In" button.
2. Create an Account or Log In:
o If You’re New to WOKWI:
 Click on "Sign Up".
 You can sign up using your email address or through platforms like
GitHub or Google.
 Follow the on-screen instructions to complete the registration.
o If You Already Have an Account:
 Click on "Sign In".
 Enter your registered email and password or use your chosen third-party
login method.

Step 3: Create a New Arduino Uno Project


1. Access Your Dashboard:
o After signing in, you’ll be redirected to your WOKWI dashboard.
2. Start a New Project:
o Click on the "New Project" button, usually located at the top-left or center of the
dashboard.
3. Select Arduino Uno:
o From the list of available boards, select "Arduino Uno" to start with a blank
Arduino Uno workspace.

Step 4: Set Up the Hardware Components


1. Access the Components Panel:
o On the right side of the workspace, locate the "Components" panel.
2. Add an Arduino Uno Board:
o If not already present, drag and drop the "Arduino Uno" board onto the
workspace.
3. Add LEDs:
o Red LED:
 Drag a "LED" component onto the breadboard.
 Change its color to red by selecting the LED and choosing red from the
properties.
o Yellow LED:
 Repeat the above step and set the LED color to yellow.
o Blue LED:
 Repeat the above step and set the LED color to blue.
4. Add a Push Button:
o Drag a "Push Button" component onto the breadboard.
5. Add Resistors:
o For each LED, add a 220Ω resistor between the LED's anode (longer leg) and
the Arduino's digital pins to limit current.
o Add a 10kΩ resistor for the push button to ensure a stable input.

Step 5: Connect the Components


1. Connect LEDs to Arduino:
o Red LED:
 Connect the cathode (shorter leg) to the GND rail on the breadboard.
 Connect the anode through a 220Ω resistor to Digital Pin 2 on the
Arduino.
o Yellow LED:
 Connect the cathode to GND.
 Connect the anode through a 220Ω resistor to Digital Pin 3.
o Blue LED:
 Connect the cathode to GND.
 Connect the anode through a 220Ω resistor to Digital Pin 4.
2. Connect Push Button to Arduino:
o Connect one side of the push button to Digital Pin 5.
o Connect the other side to 5V on the Arduino.
o Place a 10kΩ resistor between Digital Pin 5 and GND to act as a pull-down
resistor.
3. Ensure Proper Ground Connections:
o Connect the GND pin of the Arduino to the GND rail on the breadboard.

Step 6: Write the Arduino Code


1. Access the Code Editor:
o Click on the "Code" tab below the workspace to open the code editor.
2. Enter the Following Code:
Note: You can directly copy this code for this activity or make your own.

// Define LED pins


const int redLED = 2;
const int yellowLED = 3;
const int blueLED = 4;

// Define button pin


const int buttonPin = 5;

// Variables to track state


int buttonState = 0;
int lastButtonState = 0;
int pattern = 0;

unsigned long lastDebounceTime = 0;


unsigned long debounceDelay = 50;

void setup() {
// Initialize LED pins as outputs
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(blueLED, OUTPUT);

// Initialize button pin as input


pinMode(buttonPin, INPUT);
}

void loop() {
// Read the button input
int reading = digitalRead(buttonPin);

// Debounce the button


if (reading != lastButtonState) {
lastDebounceTime = millis();
}

if ((millis() - lastDebounceTime) > debounceDelay) {


if (reading != buttonState) {
buttonState = reading;
if (buttonState == HIGH) {
pattern = (pattern + 1) % 3; // Cycle through 0,1,2
}
}
}

lastButtonState = reading;

// Execute the current pattern


switch(pattern) {
case 0:
runningPattern();
break;
case 1:
blinkingPattern();
break;
case 2:
stayOnPattern();
break;
}
}

void runningPattern() {
digitalWrite(redLED, HIGH);
digitalWrite(yellowLED, LOW);
digitalWrite(blueLED, LOW);
delay(500);
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, HIGH);
delay(500);
digitalWrite(yellowLED, LOW);
digitalWrite(blueLED, HIGH);
delay(500);
digitalWrite(blueLED, LOW);
}

void blinkingPattern() {
digitalWrite(redLED, HIGH);
digitalWrite(yellowLED, HIGH);
digitalWrite(blueLED, HIGH);
delay(300);
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(blueLED, LOW);
delay(300);
}

void stayOnPattern() {
digitalWrite(redLED, HIGH);
digitalWrite(yellowLED, HIGH);
digitalWrite(blueLED, HIGH);
// No delay, stays on
}

3. Understand the Code:


o Patterns:
 Pattern 0 (Running): LEDs light up one after another in sequence.
 Pattern 1 (Blinking): All LEDs blink on and off together.
 Pattern 2 (Stay On): All LEDs remain steadily lit.
o Button Functionality:
 Each press of the button cycles to the next pattern.

Step 7: Simulate the Project


1. Start the Simulation:
o Click the "Start Simulation" button, usually located at the top of the workspace.
2. Test the Functionality:
o Observe the LEDs performing the initial pattern.
o Click the push button in the simulation to cycle through the patterns:
 First Click: Switches to the blinking pattern.
 Second Click: Switches to the stay-on pattern.
 Third Click: Returns to the running pattern, and so on.
3. Troubleshoot if Necessary:
o If the LEDs are not responding as expected, double-check your wiring and code
for any errors.

Step 8: Share and Submit Your Project


1. Generate a Shareable Link:
o Once you’re satisfied with your project, click on the "Share" button, usually found
at the top-right corner of the workspace.
2. Copy the Share Link:
o A dialog will appear with a shareable link. Click "Copy Link" to copy it to your
clipboard.
3. Submit to Google Classroom:
o Open your Google Classroom assignment where you need to submit the project.
o Paste the copied WOKWI share link into the submission field.
o Add any required comments or descriptions if necessary.
o Click "Turn In" to submit your project.
Congratulations! By completing this activity, you have successfully created a functional
Arduino Uno project on WOKWI, programmed interactive LED patterns controlled by a push
button, and demonstrated your work through comprehensive documentation. This experience
not only solidifies your foundational knowledge in Arduino programming and circuit design but
also prepares you for more advanced projects in the future.

Feel free to explore further by customizing the LED patterns, adding more components,
or integrating additional functionalities to enhance your project. Should you encounter any
challenges or have questions, refer to WOKWI’s documentation or reach out for assistance.

Happy tinkering!

You might also like