// generated by mBlock5 for <your product>
// codes make you happy
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
float PinVal = 0;
float State = 0;
void ReadKey (){
// Check Button
PinVal = digitalRead(7);
// Button Pressed
if(PinVal == 1.000000){
// Loop until button released
while(!(PinVal == 0.000000))
{
_loop();
_delay(0.1);
}
State += 1;
}
}
void _delay(float seconds) {
long endTime = millis() + seconds * 1000;
while(millis() < endTime) _loop();
}
void setup() {
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,INPUT);
// PWM sets LED brightness
analogWrite(5,0);
// Pin 6 LED enable
digitalWrite(6,0);
State = 0;
while(1) {
ReadKey();
// All LEDs on, Max Brightness
if(State == 1.000000){
analogWrite(5,255);
}
// All LEDS on, 1/2 brightness
if(State == 2.000000){
analogWrite(5,127);
}
// LEDS Strobe 2 Hz
if(State == 3.000000){
analogWrite(5,255);
digitalWrite(6,1);
_delay(0.25);
digitalWrite(6,0);
_delay(0.25);
}
// All LEDs off
if(State == 4.000000){
analogWrite(5,0);
State = 0;
}
_loop();
}
}
void _loop() {
}
void loop() {
_loop();
}