うおーるぼっとLEDのワークショップ用

Dependencies:   mbed

main.cpp

Committer:
jksoft
Date:
2017-02-04
Revision:
3:b707c09b4433
Parent:
2:20b6647c8570

File content as of revision 3:b707c09b4433:

#include "mbed.h"
#include "wallbotLED.h"

wallbotLED wb;

int main() {
    
    while(wb.GetSw1() == 0);
    
    wait(1.0);
    
    while(1) {
        int s1 = wb.GetFloorSensor1();
        int s2 = wb.GetFloorSensor2();
        int s3 = wb.GetFloorSensor3();
        int s4 = wb.GetFloorSensor4();
        
        wb.SetLedPanel(0,9,s1);
        wb.SetLedPanel(0,8,s2);
        wb.SetLedPanel(0,7,s3);
        wb.SetLedPanel(0,6,s4);
        
        if(wb.GetSw1()) {
            wb.driveLeftMotor(1.0);
        }
        else {
            wb.driveLeftMotor(0.0);
        }
        
        if(wb.GetSw2()) {
            wb.driveRightMotor(1.0);
        }
        else {
            wb.driveRightMotor(0.0);
        }
    }
}