Soap samples from Soap Group:
Discussion about forming an LLC in Massachusetts.
/* Blink without Delay
Sample code- blinks 3 LEDs at 3 independent rates
using millis() function
*/
// Set Pin numbers:
const int redLED = 13;// the number of the LED pin
const int greenLED = 11;
const int pinkLED = 9;
// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillisRED = 0;
unsigned long previousMillisGREEN = 0;
unsigned long previousMillisPINK = 0;
// interval at which to blink (milliseconds)
const long intervalRed = 1000;
const long intervalGreen = 100;
const long intervalPink = 10000;
void setup() {
// set the digital pins as output:
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
pinMode(pinkLED, OUTPUT);
}
void loop() {
unsigned long currentMillis = millis();
//---control Red LED-------------
if (currentMillis - previousMillisRED <= intervalRed)
{
digitalWrite( redLED, HIGH );
}
else if ( (currentMillis - previousMillisRED > intervalRed) && ( currentMillis - previousMillisRED < 2 * intervalRed))
{
digitalWrite( redLED, LOW);
} else {
previousMillisRED = millis();
}
//Control Green LED----------
if (currentMillis - previousMillisGREEN <= intervalGreen)
{
digitalWrite( greenLED, HIGH );
}
else if ( (currentMillis - previousMillisGREEN > intervalGreen) && ( currentMillis - previousMillisGREEN < 2 * intervalGreen))
{
digitalWrite( greenLED, LOW);
} else {
previousMillisGREEN = millis();
}
// Control Pink LED-----------------
if (currentMillis - previousMillisPINK <= intervalPink)
{
digitalWrite( pinkLED, HIGH );
}
else if ( (currentMillis - previousMillisPINK > intervalPink) && ( currentMillis - previousMillisPINK < 2 * intervalPink))
{
digitalWrite( pinkLED, LOW);
} else {
previousMillisPINK = millis();
}
}
No comments:
Post a Comment