Closed mrquincle closed 2 years ago
If an external sensor triggers an external activator or light or led via the pins on the header on the builtin, you can do the blinky exactly as you have written it:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin HEADER_LED as an output.
pinMode(HEADER_LED, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(HEADER_LED, HIGH); // turn the light on
delay(1000); // wait for a second
digitalWrite(HEADER_LED, LOW); // turn the light off
delay(1000); // wait for a second
}
Most Arduino users will not hook up the Crownstone board physically with other things.
You are describing a scenario where people add sensors to a 230V board through soldering a connector on the place of the GPIO pins and then connecting leds to those.
I am talking about the on-board switch and dimmer.
The current code is motivated by a standard blinking example. I thought it would be great to have https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink working on the Crownstone but then with your normal lights. Just replace
LED_BUILTIN
withCROWNSTONE_RELAY
.This feature request by @vliedel and @AlexDM0 asks for removal of this functionality. Hence, do not use it.
The syntax will be more something like (this is custom and can change depending on lib version):
There are a few reasons for this:
CROWNSTONE_RELAY
is an actual GPIO pin on the board.digitalWrite
won't have an effect. You will need to call a function likeCrownstone.isLocked()
andCrownstone.unlock()
beforeCrownstone.switch(1)
.analogWrite
would then have no effect.There might be a middle way in providing both.
Just don't get your hopes up. :-D