4. Embedded programming¶
Tasks of the week:¶
- Task 1: Recognize and familiarize with various types of microcontrollers.
- Task2: Required using the Arduino IDE software to program and interact with the Adafruit nRF52840 Feather microcontroller board.
- Task3: Engaged with a ESP 32 microcontroller using the Thonny IDE and programmed it with MicroPython.
- Task4:
Task 1¶
This week we started to work as groups to identify the types of microcontroller Click here to see the group work. My group worked on ESP32
Click here to see the group work -Stu link-
Task 2¶
I’ve used the Adafruit nRF52840 Feather microcontroller with the Arduino IDE for two tasks. The first task was a basic LED blink test to ensure the microcontroller was functioning correctly. The second task involved implementing Morse code using the onboard LED, demonstrating its functionality by displaying the sequence “TIE.”
At first the Adafruit nRF52840 Feather was not avaialble so i added it, Follow the steps to know how
the url is from a website…
put it here and press ok
Now click Blink to test thr MC
this is the code you … keep in mind that 1000 = 1 sec
Click Upload
u also can change it
This vedio shows as the blinking
This is the code in the previous video
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again foreverD
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a 0.1 second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(100);
I have also done mores code the word “TIE”
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again foreverD
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(3000);
// wait for a second
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(3000);
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(3000);
}
Video showing the result of the mores code
Task 3¶
After downloading follow these steps to make the software connect with the esp32
Step1: Connect it , and then click tools,Option
Step2: Select ESP32
Step3: Click Instal which is in green
Step4: Apply these selection
Step5: To see that u done the prevuios steps correctly a Boot.ph will appear
Step6: Code for blinking led
Step7: This is the code for time off and on (u can change it)
Step8: This code is for random time off and on
This is the code for a random task (Light and Buzzer and Fan will turn on when the button is pressed)
from machine import Pin
import time
LED_PIN = 26
MOTOR_PIN = 2
BUTTON_PIN = 27
BUZZ_PINS = (12, 13, 14)
LED = Pin(LED_PIN, Pin.OUT)
motor = Pin(MOTOR_PIN, Pin.OUT)
button = Pin(BUTTON_PIN, Pin.IN, Pin.PULL_DOWN)
buzz_pins = [Pin(pin, Pin.OUT) for pin in BUZZ_PINS]
while True:
if button.value() == 0:
LED.value(1)
motor.value(1)
for buzz_pin in buzz_pins:
buzz_pin.value(1)
else:
LED.value(0)
motor.value(0)
for buzz_pin in buzz_pins:
buzz_pin.value(0)
time.sleep(0.1)
This is O/P for the previous code
This is O/P for the a random with mutiple things