The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.

A COLLECTION OF TINKERCAD-ABLE PROJECTS VOLUME 1

Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by Pengiran JTMK, 2024-01-11 16:07:47

A COLLECTION OF TINKERCAD-ABLE PROJECTS: VOLUME I

A COLLECTION OF TINKERCAD-ABLE PROJECTS VOLUME 1

Keywords: arduino,tinkercad,internet of things

STEP 6: Run the simulation


STEP 6: Please scan the QR Code below to see a simulation video of the project


CONCLUSION: As shown in the video demonstration of the simulation, the LED will run a flow of light show for 2 different sequences automatically. Students are encourage to tinker with the code and add some additional LEDs.


PROJECT IV LED FLOW (PUSH BUTTON)


HARDWARE NEEDED AMOUNT Single Coloured Light Emitting Diode (LED) 6 Arduino UNO R3 1 Breadboard 1 200 Ohm Resistor 6 Push Button 1 INPUT OUTPUT Button Pressed 1st sequence of LED flow when button is pressed. 2nd sequence of LED flow when button is released. DIFFICULTY LEVEL BEGINNER


WHAT TO KNOW ABOUT LED: Also known as Light Emitting Diode (LED) Two legs/points [1 Anode (+) & 1 Cathode (-)] The colour of an LED is determined by the material used in the semiconducting element Most common colours (Red, Blue, Yellow, Orange, Green, White) The more current is being supply, the brighter it is Without a resistor to reduce the current, the shorter its lifespan will be


STEP 1: Arrange Arduino UNO and Breadboard as below. Insert an LED into the breadboard with the Anode (positive leg) on the left and the Cathode (negative leg on the right). Insert the button as shown.


STEP 2: Connect the 200 Ohm resistor to the Anode of the LED as shown.


STEP 3: Connect the Cathode of LED to -VE point of breadboard. Connect the button to -VE point of the breadboard. Then connect it to GND of the Arduino UNO.


STEP 4: Connect the LEDs to PIN 13 to PIN 8 via the resistors as shown. Make sure it connect to the resistor to control the current going into the LEDs later on. Connect the button to PIN 7.


STEP 5: Insert the following code (next page) inside code tab of Tinkercad project


STEP 5: The code as shown in previous page: int leds[] = {13, 12, 11, 10, 9, 8}; int numLeds = 6; const int Button_Pin = 7; void setup() { for (int i = 0; i < numLeds; pinMode(leds[i++], OUTPUT)); pinMode(Button_Pin, INPUT_PULLUP); } void loop() { int buttonState = digitalRead(Button_Pin); if (buttonState == LOW) { flowLeftToRight(); } else { blinkOddToEven(); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18


STEP 5: Continue: void flowLeftToRight() { for (int i = 0; i < numLeds; i++) { digitalWrite(leds[i], HIGH); delay(100); digitalWrite(leds[i], LOW); delay(100); } delay(100); for (int i = numLeds - 1; i >= 0; i--) { digitalWrite(leds[i], HIGH); delay(100); digitalWrite(leds[i], LOW); delay(100); } delay(100); } 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36


STEP 5: Continue: void blinkOddToEven() { for (int j = 0; j < 2; j++) { for (int i = 0; i < numLeds; digitalWrite(leds[i], HIGH), i += 2); delay(150); for (int i = 0; i < numLeds; digitalWrite(leds[i], LOW), i += 2); for (int i = 1; i < numLeds; digitalWrite(leds[i], HIGH), i += 2); delay(150); for (int i = 1; i < numLeds; digitalWrite(leds[i], LOW), i += 2); delay(150); } } 37 38 39 40 41 42 43 44 45 46 47 48


STEP 6: Run the simulation


STEP 6: Please scan the QR Code below to see a simulation video of the project


CONCLUSION: As shown in the video demonstration of the simulation, the LED will run a flow of light show for 2 different sequences automatically. 1st sequence will play when the button is pressed and when the button is released, 2nd sequence will play. Students are encourage to tinker with the code and add some additional LEDs.


PROJECT V LED RGB BLINK COLOUR CHANGE (AUTO)


HARDWARE NEEDED AMOUNT RGB LED 1 Arduino UNO R3 1 Breadboard 1 200 Ohm Resistor 3 INPUT OUTPUT NONE RGB LED will blink 3 different colours randomly with interval or 1 seconds. DIFFICULTY LEVEL BEGINNER


WHAT TO KNOW ABOUT RGB LED: They are two types of RGB LED: Common Cathode Common Anode It comes 4 legs/pin. 1 for Red, 1 for Green, 1 Blue and 1 for either Cathode (-) or Anode (+). User can basically either create Red colour light, or green coloured light or blue coloured light. User can also create combination colour from two or three of the basic light (Red, Green, Blue) to make a whole new colour of light. The combination of light is endless.


COMMON CATHODE RGB LED In an RGB LED with a common cathode configuration, the internal LEDs share a common cathode connected to the external cathode lead. To individually control each color, you must provide a HIGH signal or connect to VCC for the red, green, and blue leads, while connecting the anode lead to the negative terminal of the power supply. COMMON CATHODE RGB LED In an RGB LED with a common anode configuration, the internal LEDs share a common anode connected to the external anode lead. To individually control each color, you must provide a LOW signal or ground for the red, green, and blue leads, while connecting the anode lead to the positive terminal of the power supply.


STEP 1: Arrange Arduino UNO and Breadboard as below. Insert an RGB LED into the breadboard with the. Connect 200 Ohm resistor on each of the RGB LED pin excluding the common pin.


STEP 2: Connect the RGB LED common pin to the -VE of the breadboard. Connect it to the GND of the Arduino board.


STEP 3: Connect the RGB LED pins to PIN 13, 12 and 11 on the Arduino board. Red pin to 12, Blue pin to 12 and Green pin to 11.


STEP 4: Insert the following code (next page) inside code tab of Tinkercad project


STEP 4: The code as shown in previous page: // Define pin numbers for R=Red, G=Green, and B=Blue LEDs #define R 13 #define G 12 #define B 11 // Define RGB array with Red, Green, Blue, Yellow, Purple, and White values int rgb[] = {255, 0, 0, // Red 0, 255, 0, // Green 0, 0, 255, // Blue 255, 255, 0, // Yellow 255, 0, 255, // Purple 255, 255, 255}; // White void setup() { // Set the pin modes to OUTPUT for RGB LEDs pinMode(R, OUTPUT); pinMode(G, OUTPUT); pinMode(B, OUTPUT); } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20


STEP 4: Continue: void loop() { // Loop through the RGB array and set each color with a 100ms interval for (int i = 0; i < 18; i += 3) { setColor(rgb[i], rgb[i + 1], rgb[i + 2]); delay(500); } } // Function to set RGB color void setColor(int red, int green, int blue) { analogWrite(R, red); analogWrite(G, green); analogWrite(B, blue); } 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37


STEP 5: Run the simulation


STEP 6: Please scan the QR Code below to see a simulation video of the project


CONCLUSION: As shown in the video demonstration of the simulation, the RGB LED will blink colour from Red, Green, Blue, Purple, Yellow and White. Students are encourage to tinker with the code and add some additional LEDs.


PROJECT VI LED RGB BLINK COLOUR CHANGE (PUSH BUTTON)


HARDWARE NEEDED AMOUNT RGB LED 1 Arduino UNO R3 1 Breadboard 1 200 Ohm Resistor 3 Push Button 1 INPUT OUTPUT NONE RGB LED will blink 3 different colours randomly with interval or 1 seconds. DIFFICULTY LEVEL BEGINNER


WHAT TO KNOW ABOUT RGB LED: They are two types of RGB LED: Common Cathode Common Anode It comes 4 legs/pin. 1 for Red, 1 for Green, 1 Blue and 1 for either Cathode (-) or Anode (+). User can basically either create Red colour light, or green coloured light or blue coloured light. User can also create combination colour from two or three of the basic light (Red, Green, Blue) to make a whole new colour of light. The combination of light is endless.


COMMON CATHODE RGB LED In an RGB LED with a common cathode configuration, the internal LEDs share a common cathode connected to the external cathode lead. To individually control each color, you must provide a HIGH signal or connect to VCC for the red, green, and blue leads, while connecting the anode lead to the negative terminal of the power supply. COMMON CATHODE RGB LED In an RGB LED with a common anode configuration, the internal LEDs share a common anode connected to the external anode lead. To individually control each color, you must provide a LOW signal or ground for the red, green, and blue leads, while connecting the anode lead to the positive terminal of the power supply.


STEP 1: Arrange Arduino UNO and Breadboard as below. Insert an RGB LED into the breadboard with the. Connect 200 Ohm resistor on each of the RGB LED pin excluding the common pin. Add push button on the breadboard.


STEP 2: Connect the RGB LED common pin to the -VE of the breadboard. Connect push button to -VE of the breadboard. Connect it to the GND of the Arduino board.


STEP 3: Connect the RGB LED pins to PIN 13, 12 and 11 on the Arduino board. Red pin to 12, Blue pin to 12 and Green pin to 11. Connect push button to PIN 7 on the Arduino board.


STEP 4: Insert the following code (next page) inside code tab of Tinkercad project


STEP 4: The code as shown in previous page: // Define pin numbers for R=Red, G=Green, and B=Blue LEDs #define R 13 #define G 11 #define B 12 // Define the pin for the button const int buttonPin = 7; void setup() { // Set the pin modes to OUTPUT for RGB LEDs pinMode(R, OUTPUT); pinMode(G, OUTPUT); pinMode(B, OUTPUT); // Set button pin as INPUT_PULLUP; use internal pull-up resistor pinMode(buttonPin, INPUT_PULLUP); } void loop() { // Check if the button is pressed if (digitalRead(buttonPin) == LOW) { // If the button is pressed, toggle the color toggleColor(); delay(500); // Debounce delay to avoid multiple readings for a single press } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27


STEP 4: Continue: // Function to toggle RGB color on and off void toggleColor() { for (int i = 0; i < 10; ++i) { // Blink 10 times // Generate random values for Red, Green, and Blue components int redValue = random(256); int greenValue = random(256); int blueValue = random(256); // Set RGB LED to the random color and make it blink analogWrite(R, redValue); analogWrite(G, greenValue); analogWrite(B, blueValue); delay(500); // On time // Turn off the RGB LED analogWrite(R, 0); analogWrite(G, 0); analogWrite(B, 0); delay(500); // Off time } } 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51


STEP 5: Run the simulation


STEP 6: Please scan the QR Code below to see a simulation video of the project


CONCLUSION: As shown in the video demonstration of the simulation, the RGB LED will blink random colour for ten times once the push button was pressed. Students are encourage to tinker with the code and add some additional LEDs.


REFERENCES 87


(online) e ISBN 978-967-2097-87-7 POLITEKNIK MUKAH A COLLECTION OF TINKERCAD-ABLE PROJECTS: VOLUME I 9 789672 097877


Click to View FlipBook Version