Report 6 Corrected Pages
Report 6 Corrected Pages
1 Circuit Schematics
#include <AnalogIO.h>
#include <PulseSensorPlayground.h>
//#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Arduino_FreeRTOS.h>
#include "task.h"
#include "semphr.h"
#include <TimeLib.h>
#include <DS1307RTC.h>
int timeout = 0;
unsigned long seconds;
unsigned int minutes;
unsigned int hours;
unsigned int BPM ;
unsigned int steps = 0;
uint8_t disp_clear = 0;
tmElements_t tm;
PulseSensorPlayground pulseSensor;
SemaphoreHandle_t rtcSem;
SemaphoreHandle_t displaySem;
while (1)
{
// Assuming STEP_SENSOR_PIN is an analog pin, read its value
int vibrationValue = analogRead(STEP_SENSOR_PIN);
void vApplicationIdleHook()
{
if (xSemaphoreTake(sem, portMAX_DELAY) == pdPASS)
{
Serial.println("update test 1");
BPM = pulseSensor.getBeatsPerMinute();
Serial.println(BPM);
xSemaphoreGive(sem);
}
}
void setup()
{
Serial.begin(9600);
setSyncProvider(RTC.get); // Set the RTC as the time provider
sem = xSemaphoreCreateBinary();
if (sem != NULL)
{
xSemaphoreGive(sem);
}
pinMode(LEDPIN, OUTPUT);
pinMode(inputpin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(inputpin), button_press, FALLING);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3D))
{
Serial.println("SSD1306 allocation failed");
while (1)
; // Don't proceed, loop forever
}
display.clearDisplay();
display.setTextColor(WHITE);
Serial.println("1");
xTaskCreate(Display, "Display", 4096, NULL, 1, &xHandleD);
xTaskCreate(Time, "Time", 128, NULL, 2, &xHandleT);
xTaskCreate(vibrationMonitor, "VibrationMonitor", 1000, NULL, 3, NULL); // Create
the vibration monitoring task
vTaskStartScheduler();
}
void loop() {}
void button_press()
{
timeout = 0;
}
void updateData() {
while (1) {
if (xSemaphoreTake(displaySem, pdMS_TO_TICKS(100)) == pdTRUE) {
Serial.println("update test 1");
// Generate a new random BPM every 100 milliseconds
hours = tm.Hour;
minutes = tm.Minute;
seconds = tm.Second;
Serial.println(RTC.read(tm));
xSemaphoreGive(displaySem);
}
vTaskDelay(pdMS_TO_TICKS(100));
}
}