Micro-controllers, wireless transmission and database
This project assumes you have already installed STM32CubeIDE. You need to have previously done a basic blink sketch with blue-pill using STM32CubeIDE. I have made a complete video from installing STM32CubeIDE to LED blink program. You can watch it by clicking this link. https://www.youtube.com/watch?v=kXg467nVd_A
Set PB6, PB8 and PB9 to GPIO_Output
/* USER CODE BEGIN 0 */ #define SER_PIN GPIO_PIN_6 #define SER_PORT GPIOB #define RCLK_PIN GPIO_PIN_8 #define RCLK_PORT GPIOB #define SRCLK_PIN GPIO_PIN_9 #define SRCLK_PORT GPIOB uint16_t currentVal = 0b0000000000000000; void HC595write() { for(int i=0; i<16; i++) { if(currentVal & (1<<i)) { HAL_GPIO_WritePin(SER_PORT, SER_PIN, GPIO_PIN_SET); } else { HAL_GPIO_WritePin(SER_PORT, SER_PIN, GPIO_PIN_RESET); } HAL_GPIO_WritePin(SRCLK_PORT, SRCLK_PIN, GPIO_PIN_SET); HAL_GPIO_WritePin(SRCLK_PORT, SRCLK_PIN, GPIO_PIN_RESET); } HAL_GPIO_WritePin(RCLK_PORT, RCLK_PIN, GPIO_PIN_SET); HAL_GPIO_WritePin(RCLK_PORT, RCLK_PIN, GPIO_PIN_RESET); } void HC595writePin(uint8_t pin, uint8_t value) { if (value == 0) { currentVal &= ~(1 << pin); } else { currentVal |= (1 << pin); } HC595write(); } /* USER CODE END 0 */ /* USER CODE BEGIN 2 */ // Set all pins "ON" currentVal = 0b1111111111111111; HC595write(); HAL_Delay(1000); // Set selected pins "ON" // OFF-OFF-ON-ON-ON-ON-OFF-OFF-OFF-OFF-ON-ON-ON-ON-OFF-OFF currentVal = 0b0011110000111100; HC595write(); HAL_Delay(1000); // Set all pins "OFF" currentVal = 0b0000000000000000; HC595write(); HAL_Delay(200); HC595writePin(0, 1); // Set First Module pin 0 "ON" HAL_Delay(200); HC595writePin(1, 1); // Set First Module pin 1 "ON" HAL_Delay(200); HC595writePin(2, 1); // Set First Module pin 2 "ON" HAL_Delay(200); HC595writePin(3, 1); // Set First Module pin 3 "ON" HAL_Delay(200); HC595writePin(4, 1); // Set First Module pin 4 "ON" HAL_Delay(200); HC595writePin(5, 1); // Set First Module pin 5 "ON" HAL_Delay(200); HC595writePin(6, 1); // Set First Module pin 6 "ON" HAL_Delay(200); HC595writePin(7, 1); // Set First Module pin 7 "ON" HAL_Delay(200); HC595writePin(8, 1); // Set Second Module pin 0 "ON" HAL_Delay(200); HC595writePin(9, 1); // Set Second Module pin 1 "ON" HAL_Delay(200); HC595writePin(10, 1); // Set Second Module pin 2 "ON" HAL_Delay(200); HC595writePin(11, 1); // Set Second Module pin 3 "ON" HAL_Delay(200); HC595writePin(12, 1); // Set Second Module pin 4 "ON" HAL_Delay(200); HC595writePin(13, 1); // Set Second Module pin 5 "ON" HAL_Delay(200); HC595writePin(14, 1); // Set Second Module pin 6 "ON" HAL_Delay(200); HC595writePin(15, 1); // Set Second Module pin 7 "ON" HAL_Delay(200); HC595writePin(0, 0); // Set First Module pin 0 "OFF" HAL_Delay(200); HC595writePin(1, 0); // Set First Module pin 1 "OFF" HAL_Delay(200); HC595writePin(2, 0); // Set First Module pin 2 "OFF" HAL_Delay(200); HC595writePin(3, 0); // Set First Module pin 3 "OFF" HAL_Delay(200); HC595writePin(4, 0); // Set First Module pin 4 "OFF" HAL_Delay(200); HC595writePin(5, 0); // Set First Module pin 5 "OFF" HAL_Delay(200); HC595writePin(6, 0); // Set First Module pin 6 "OFF" HAL_Delay(200); HC595writePin(7, 0); // Set First Module pin 7 "OFF" HAL_Delay(200); HC595writePin(8, 0); // Set Second Module pin 0 "OFF" HAL_Delay(200); HC595writePin(9, 0); // Set Second Module pin 1 "OFF" HAL_Delay(200); HC595writePin(10, 0); // Set Second Module pin 2 "OFF" HAL_Delay(200); HC595writePin(11, 0); // Set Second Module pin 3 "OFF" HAL_Delay(200); HC595writePin(12, 0); // Set Second Module pin 4 "OFF" HAL_Delay(200); HC595writePin(13, 0); // Set Second Module pin 5 "OFF" HAL_Delay(200); HC595writePin(14, 0); // Set Second Module pin 6 "OFF" HAL_Delay(200); HC595writePin(15, 0); // Set Second Module pin 7 "OFF" HAL_Delay(200); // Binary counter for(int counter=0; counter<65536; counter++) { currentVal = counter; HC595write(); HAL_Delay(30); } /* USER CODE END 2 */