File Switch3.cpp¶
File List > examples > Switch3 > Switch3.cpp
Go to the documentation of this file
Source Code¶
#include "daisy_seed.h"
using namespace daisy;
DaisySeed hw;
Switch3 toggle;
int main(void)
{
hw.Init();
toggle.Init(seed::D29, seed::D30);
while(1)
{
bool slow_blink = (System::GetNow() & 1023) < 511;
bool fast_blink = (System::GetNow() & 511) < 255;
switch(toggle.Read())
{
case Switch3::POS_LEFT: hw.SetLed(false); break;
case Switch3::POS_CENTER: hw.SetLed(slow_blink); break;
case Switch3::POS_RIGHT: hw.SetLed(fast_blink); break;
}
}
}