Page 196 - Programming the Photon Getting Started With the Internet of Things
P. 196
Return Value
None
Example
analogWrite(A7, 127);
This pulses analog pin 7 so that it is turned off 50% of the time. If you are using an LED,
this will be half the brightness.
digitalRead
This reads the value of a digital input and returns a value of HIGH or LOW, meaning the
pin is either ON or OFF.
Syntax
digitalRead(pin);
Return Value
HIGH or LOW
Parameters
pin
The digital pin number.
Example
if (digitalRead(D0) == HIGH) {
Serial.println("Pin 0 is HIGH")
}
This prints out in the serial box “Pin 0 is HIGH” when digital pin 0 is connected to 3V3.
digitalWrite
This function sets the digital pin to either HIGH or LOW, where LOW is GND and HIGH
is 3V3.