Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include "utilities.h"
- #include "io.hpp"
- #include <stdbool.h>
- #include "gpio.hpp"
- typedef enum{IDLE, MORNING} State;
- int main(void){
- State currentState = IDLE;
- int light_value = LS.getPercentValue();
- GPIO pin20(P1_20);
- pin20.setAsOutput();
- pin20.setLow();
- int temp1 = 1;
- while(1){
- //LD.setNumber(light_value);
- delay_ms(100);
- switch(currentState){
- case IDLE:
- while(temp1){
- printf("IDLE\n");
- printf("IDLE\n");
- if(SW.getSwitch(1)){
- currentState = MORNING;
- printf("After Declaring State");
- temp1=0;
- //break;
- }
- }
- printf("Break2");
- delay_ms(100);
- printf("Delay3");
- currentState = MORNING;
- printf("Delay4");
- delay_ms(100);
- printf("Delay5");
- break;
- case MORNING:
- printf("Morning0\n");
- while(1){
- //printf("Morning\n");
- light_value = LS.getPercentValue();
- if(light_value<4096){
- //printf("SETHIGH");
- pin20.setHigh();
- }else{
- printf("SETLOW");
- pin20.setLow();
- }
- }
- if(SW.getSwitch(1)){
- currentState = IDLE;
- }
- break;
- /***
- *
- *
- pin20.setHigh();
- pin20.setLow();
- delay_ms(200);
- // Switch #1
- if(SW.getSwitch(1)) {
- LE.on(1);
- }
- else {
- LE.off(1);
- }
- //Switch #2
- if(SW.getSwitch(2)){
- int light_value = LS.getPercentValue();
- LD.setNumber(light_value);
- }*////
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement