ESI Arduino IDE Examples
ESI Arduino IDE Examples
Objective:
The objective of this experiment is to learn how to control LED with an STM32 microcontroller. This
experiment aims to demonstrate the basic setup and usage of controlling a LED with STM32.
Materials Required:
2. ST-LINK
3. Arduino IDE.
Procedure:
2. Set up the Arduino IDE with the appropriate board support and create a new Sketch File.
5. Open a COM Test Serial with the correct baud rate (9600 in this case) to observe the transmitted
message.
Code:
void setup()
pinMode(PC13, OUTPUT);
}
void loop()
digitalWrite(PC13, HIGH);
delay(500);
digitalWrite(PC13, LOW);
delay(500);
}
Conclusion:
Experiment No.
Objective:
The objective of this experiment is to learn how to get ADC values with an STM32 microcontroller.
This experiment aims to demonstrate the basic setup and usage of internal ADC of STM32.
Materials Required:
2. ST-LINK
3. Arduino IDE.
Procedure:
2. Set up the Arduino IDE with the appropriate board support and create a new Sketch File.
5. Open a COM Test Serial with the correct baud rate (9600 in this case) to observe the transmitted
message.
Code:
void setup()
pinMode(PA0, INPUT);
Serial.begin(9600);
}
void loop()
Serial.println(adcVal);
delay(50);
}
Conclusion:
Experiment No.
Objective:
The objective of this experiment is to learn how to implement UART over USB with an STM32
microcontroller. This experiment aims to demonstrate the basic setup and usage of controlling UART
with STM32.
Materials Required:
2. ST-LINK
6. Arduino IDE.
Procedure:
2. Set up the Arduino IDE with the appropriate board support and create a new Sketch File.
5. Open a COM Test Serial with the correct baud rate (9600 in this case) to observe the transmitted
message.
Code:
void setup()
Serial.begin(9600);
}
void loop()
Delay(1000);
}
Conclusion
Experiment No.
Objective:
The objective of this experiment is to learn how to control I2C LCD with an STM32 microcontroller.
Materials Required:
2. ST-LINK
3. 16x2 LCD
5. Power Supply.
6. Arduino IDE.
Procedure:
2. Set up the Arduino IDE with the appropriate board support and create a new Sketch File.
3. Write program to perform the controlling of a motor with help of a motor driver.
5. Open a COM Test Serial with the correct baud rate (9600 in this case) to observe the transmitted
message.
Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x3F for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("STM32 I2C ");
lcd.setCursor(0,1);
lcd.print("LCD DEMO");
}
void loop()
{
// Do nothing here…
}
Conclusion:
Experiment No.
Objective:
The objective of this experiment is to learn how to control DC motors using a Motor Driver with an
STM32 microcontroller. This experiment aims to demonstrate the basic setup and usage of
controlling a motor driver such as an L293 / L298D driver with STM32.
Materials Required:
2. ST-LINK
4. DC Motor.
5. Power Supply.
6. Arduino IDE.
Procedure:
2. Set up the Arduino IDE with the appropriate board support and create a new Sketch File.
3. Write program to perform the controlling of a motor with help of a motor driver.
5. Open a COM Test Serial with the correct baud rate (9600 in this case) to observe the transmitted
message.
Code:
int motorA;
bool motorDir;
void setup() {
Serial.begin(9600);
pinMode(inputPin, INPUT_PULLUP);
pinMode(motor1R, OUTPUT);
pinMode(motor1L, OUTPUT);
void loop() {
motorA = digitalRead(inputPin);
if(motorA == HIGH)
{
digitalWrite(motor1R, HIGH);
digitalWrite(motor1L, LOW);
motorDir = true;
}
switch(motorDir)
{
case true:
Serial.print(" Clockwise");
break;
case false:
Serial.print(" Anti-Clockwise");
break;
}
Serial.print("\n");
delay(100);
Conclusion:
Experiment No.
Objective:
The objective of this experiment is to learn how to control HC-05 Bluetooth Module with an STM32
microcontroller.
Materials Required:
2. ST-LINK
4. Power Supply.
5. Arduino IDE.
Procedure:
2. Set up the Arduino IDE with the appropriate board support and create a new Sketch File.
3. Write program to perform the controlling of a motor with help of a motor driver.
5. Open a COM Test Serial with the correct baud rate (9600 in this case) to observe the transmitted
message.
Code:
char data = 0;
void setup() {
Serial1.begin(9600);
pinMode(LED,OUTPUT);
}
void loop() {
if(Serial1.available()> 0)
data = Serial1.read();
if(data == 'A')
digitalWrite(LED, HIGH);
Serial1.print("LED ON\n");
if(data == 'a')
digitalWrite(LED, LOW);
Serial1.print("LED OFF\n");
Conclusion: