This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "stm32f4xx_hal.h" | |
| #include "stdio.h" | |
| #define LIS3DH_ADDRESS 0x18 // I2C address of LIS3DH accelerometer | |
| I2C_HandleTypeDef hi2c1; // I2C interface handle | |
| UART_HandleTypeDef huart2; // UART interface handle | |
| void SystemClock_Config(void); | |
| void print_acceleration(float ax, float ay, float az); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "stm32f10x.h" // Include the STM32F10x header file | |
| int main(void) | |
| { | |
| // Enable clock for GPIO port C | |
| RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); | |
| // Initialize GPIO pins for LED outputs | |
| GPIO_InitTypeDef GPIO_InitStructure; | |
| GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const int PROXIMITY_SENSOR_PIN = 2; // digital pin for proximity sensor input | |
| const int LED_PIN = 13; // digital pin for LED output | |
| int sensorValue = 0; // variable to store sensor value | |
| void setup() { | |
| pinMode(PROXIMITY_SENSOR_PIN, INPUT); // set the proximity sensor pin as input | |
| pinMode(LED_PIN, OUTPUT); // set the LED pin as output | |
| Serial.begin(9600); // initialize serial communication at 9600 baud rate | |
| } | |
| void loop() { | |
| sensorValue = digitalRead(PROXIMITY_SENSOR_PIN); // read digital sensor value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const int LDR_PIN = A0; // analog pin for LDR input | |
| int LDR_value = 0; // variable to store LDR value | |
| void setup() { | |
| Serial.begin(9600); // initialize serial communication at 9600 baud rate | |
| } | |
| void loop() { | |
| LDR_value = analogRead(LDR_PIN); // read LDR value | |
| Serial.print("LDR Value: "); // print LDR value to serial monitor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void setup() { | |
| // set all digital pins from 2 to 9 as outputs | |
| for (int i = 2; i <= 9; i++) { | |
| pinMode(i, OUTPUT); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void setup() { | |
| pinMode(13, OUTPUT); // set digital pin 13 as output | |
| } | |
| void loop() | |
| { | |
| digitalWrite(13, HIGH); // turn on the LED | |
| delay(1000); // wait for 1 second | |
| digitalWrite(13, LOW); // turn off the LED | |
| delay(1000); // wait for 1 second | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void setup() { | |
| pinMode(2, OUTPUT); // set red LED pin as output | |
| pinMode(3, OUTPUT); // set yellow LED pin as output | |
| pinMode(4, OUTPUT); // set green LED pin as output | |
| } | |
| void loop() { | |
| digitalWrite(2, HIGH); // turn on red LED | |
| delay(5000); // wait for 5 seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int sensorValue = 0; | |
| void setup() | |
| { | |
| pinMode(A0, INPUT); | |
| pinMode(13, OUTPUT); | |
| Serial.begin(9600); | |
| } | |
| void loop() | |
| { | |
| // read the value from the sensor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<LiquidCrystal.h> | |
| #define RS 9 | |
| #define E 8 | |
| #define D4 4 | |
| #define D5 5 | |
| #define D6 6 | |
| #define D7 7 | |
| #define MENU 3 | |
| #define FIRST 1 | |
| #define SECOND 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int LDR_Value = 0; | |
| int LDR_Value1=0; | |
| void setup() | |
| { | |
| pinMode(A1, INPUT); | |
| pinMode(13, OUTPUT); | |
| Serial.begin(9600); | |
| } |
NewerOlder