School project.
Dependencies: Timezone NTPClient BSP_DISCO_F746NG Grove_temperature
main.cpp@8:1a1e7cf7dcb6, 2021-01-14 (annotated)
- Committer:
- tuxx0046
- Date:
- Thu Jan 14 12:41:37 2021 +0000
- Revision:
- 8:1a1e7cf7dcb6
- Parent:
- 7:b80c993f4db5
- Child:
- 9:fd1f07a4a0ff
Refactored and renamed functions and file to better suit future needs.; light_sensor_functions -> helper_functions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tuxx0046 | 1:1ee11539cc43 | 1 | /** |
tuxx0046 | 0:ed4063a0a4d5 | 2 | @file main.cpp |
tuxx0046 | 0:ed4063a0a4d5 | 3 | @brief Light Control System to automatically dimmer or increase light levels depending on registered light intensity. |
tuxx0046 | 6:aecab8e3acad | 4 | Made for: |
tuxx0046 | 6:aecab8e3acad | 5 | STM32F746G-DISCOVERY |
tuxx0046 | 6:aecab8e3acad | 6 | Grove Base Shield v2.1 |
tuxx0046 | 6:aecab8e3acad | 7 | Grove Light Sensor v1.2 |
tuxx0046 | 6:aecab8e3acad | 8 | Grove Rotary Angle Sensor v1.2 |
tuxx0046 | 6:aecab8e3acad | 9 | Grove LED Socket Kit v1.5 |
tuxx0046 | 6:aecab8e3acad | 10 | Grove LED diode |
tuxx0046 | 6:aecab8e3acad | 11 | Grove Button v1.2 |
tuxx0046 | 6:aecab8e3acad | 12 | |
tuxx0046 | 0:ed4063a0a4d5 | 13 | @author Tu Tri Huynh |
tuxx0046 | 0:ed4063a0a4d5 | 14 | @date 1/13/2021 |
tuxx0046 | 0:ed4063a0a4d5 | 15 | */ |
tuxx0046 | 0:ed4063a0a4d5 | 16 | |
tuxx0046 | 0:ed4063a0a4d5 | 17 | #include "mbed.h" |
tuxx0046 | 6:aecab8e3acad | 18 | |
tuxx0046 | 6:aecab8e3acad | 19 | AnalogIn light_sensor(A0); |
tuxx0046 | 6:aecab8e3acad | 20 | PwmOut led(D3); |
tuxx0046 | 6:aecab8e3acad | 21 | |
tuxx0046 | 0:ed4063a0a4d5 | 22 | char building[31]; |
tuxx0046 | 0:ed4063a0a4d5 | 23 | char room[31]; |
tuxx0046 | 0:ed4063a0a4d5 | 24 | |
tuxx0046 | 2:90d31841523a | 25 | /// Used to test the controller and make sure that it functions |
tuxx0046 | 6:aecab8e3acad | 26 | /** DigitalOut myled(LED1); */ |
tuxx0046 | 0:ed4063a0a4d5 | 27 | |
tuxx0046 | 3:02e7aac23ff9 | 28 | #include "setup_functions.h" |
tuxx0046 | 4:1a12157689a7 | 29 | #include "lcd_functions.h" |
tuxx0046 | 6:aecab8e3acad | 30 | #include "led_functions.h" |
tuxx0046 | 8:1a1e7cf7dcb6 | 31 | #include "helper_functions.h" |
tuxx0046 | 0:ed4063a0a4d5 | 32 | |
tuxx0046 | 0:ed4063a0a4d5 | 33 | int main(){ |
tuxx0046 | 0:ed4063a0a4d5 | 34 | /* |
tuxx0046 | 4:1a12157689a7 | 35 | lcd_initialize(); |
tuxx0046 | 4:1a12157689a7 | 36 | lcd_show_setup_screen(); |
tuxx0046 | 6:aecab8e3acad | 37 | setup_run_setup();*/ |
tuxx0046 | 6:aecab8e3acad | 38 | |
tuxx0046 | 6:aecab8e3acad | 39 | float light_sensor_reading; |
tuxx0046 | 2:90d31841523a | 40 | while(1) |
tuxx0046 | 2:90d31841523a | 41 | { |
tuxx0046 | 6:aecab8e3acad | 42 | light_sensor_reading = light_sensor.read(); |
tuxx0046 | 6:aecab8e3acad | 43 | printf("%1.2f\n", light_sensor_reading); |
tuxx0046 | 8:1a1e7cf7dcb6 | 44 | printf("%i%%\n", helper_get_sensor_read_in_percent(light_sensor_reading)); |
tuxx0046 | 6:aecab8e3acad | 45 | led_set_blink_rate(light_sensor_reading); |
tuxx0046 | 6:aecab8e3acad | 46 | wait_us(1000000); |
tuxx0046 | 4:1a12157689a7 | 47 | |
tuxx0046 | 2:90d31841523a | 48 | /** 01/13/2021 Used to test the controller and make sure that it functions.*/ |
tuxx0046 | 2:90d31841523a | 49 | /** |
tuxx0046 | 2:90d31841523a | 50 | printf("This is a test.\n"); |
tuxx0046 | 2:90d31841523a | 51 | myled = 1; |
tuxx0046 | 2:90d31841523a | 52 | wait_us(1000000); |
tuxx0046 | 2:90d31841523a | 53 | myled = 0; |
tuxx0046 | 2:90d31841523a | 54 | wait_us(1000000); |
tuxx0046 | 2:90d31841523a | 55 | */ |
tuxx0046 | 2:90d31841523a | 56 | } |
tuxx0046 | 6:aecab8e3acad | 57 | |
tuxx0046 | 6:aecab8e3acad | 58 | /** |
tuxx0046 | 6:aecab8e3acad | 59 | printf("Mbed OS version: %d,%d,%d\n\n",MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); |
tuxx0046 | 6:aecab8e3acad | 60 | */ |
tuxx0046 | 0:ed4063a0a4d5 | 61 | } |