![]() |
RUI3 (RAK Unified Interface 3) - RAK4631
|
Functions | |
void | tone (uint8_t pin, uint32_t frequency, uint64_t duration=0) |
void | noTone (uint8_t pin) |
void | shiftOut (uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val) |
uint32_t | shiftIn (uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) |
unsigned long | pulseIn (uint8_t pin, uint8_t state, unsigned long timeout=1000000L) |
unsigned long | pulseInLong (uint8_t pin, uint8_t state, unsigned long timeout=1000000L) |
void tone | ( | uint8_t | pin, |
uint32_t | frequency, | ||
uint64_t | duration = 0 |
||
) |
Only one tone can be generated at a time. If a tone is already playing on a different pin, the call to tone() will have no effect. If the tone is playing on the same pin, the call will set its frequency.
pin | The device pin on which to generate the tone |
frequency | The frequency of the tone in hertz |
duration(optional) | The duration of the tone in milliseconds(default = no timeout) |
uint8_t ledPin = 36; uint8_t pulsePin = 13; unsigned long duration; void setup() { Serial.begin(115200); pinMode(pulsePin, INPUT_PULLUP); pinMode(ledPin, OUTPUT); } void loop() { duration = pulseIn(pulsePin, LOW); Serial.print("Pulse duration = "); Serial.print((float)duration/1000000); Serial.println(" sec"); if(duration >= 15000000) noTone(ledPin); else if(duration >= 10000000) tone(ledPin, 494, 5000); else if(duration >= 5000000) tone(ledPin, 494); }
void noTone | ( | uint8_t | pin | ) |
pin | The device pin on which to stop generating the tone |
uint8_t ledPin = 36; uint8_t pulsePin = 13; unsigned long duration; void setup() { Serial.begin(115200); pinMode(pulsePin, INPUT_PULLUP); pinMode(ledPin, OUTPUT); } void loop() { duration = pulseIn(pulsePin, LOW); Serial.print("Pulse duration = "); Serial.print((float)duration/1000000); Serial.println(" sec"); if(duration >= 15000000) noTone(ledPin); else if(duration >= 10000000) tone(ledPin, 494, 5000); else if(duration >= 5000000) tone(ledPin, 494); }
void shiftOut | ( | uint8_t | dataPin, |
uint8_t | clockPin, | ||
uint8_t | bitOrder, | ||
uint8_t | val | ||
) |
dataPin | the pin on which to output each bit |
clockPin | the pin to toggle once the dataPin has been set to the correct value |
bitOrder | which order to shift out the bits; either MSBFIRST or LSBFIRST |
val | the data to shift out |
uint32_t shiftIn | ( | uint8_t | dataPin, |
uint8_t | clockPin, | ||
uint8_t | bitOrder | ||
) |
dataPin | the pin on which to output each bit |
cloackPin | the pin to toggle once the dataPin has been set to the correct value |
bitOrder | which order to shift out the bits; either MSBFIRST or LSBFIRST |
unsigned long pulseIn | ( | uint8_t | pin, |
uint8_t | state, | ||
unsigned long | timeout = 1000000L |
||
) |
pin | the pin on which you want to read a pulse |
state | type of pulse to read: either HIGH or LOW |
timeout(optional) | the number of microseconds to wait for the pulse to start; default is one second |
uint8_t ledPin = 36; uint8_t pulsePin = 13; unsigned long duration; void setup() { Serial.begin(115200); pinMode(pulsePin, INPUT_PULLUP); pinMode(ledPin, OUTPUT); } void loop() { duration = pulseIn(pulsePin, LOW); Serial.print("Pulse duration = "); Serial.print((float)duration/1000000); Serial.println(" sec"); if(duration >= 15000000) noTone(ledPin); else if(duration >= 10000000) tone(ledPin, 494, 5000); else if(duration >= 5000000) tone(ledPin, 494); }
unsigned long pulseInLong | ( | uint8_t | pin, |
uint8_t | state, | ||
unsigned long | timeout = 1000000L |
||
) |
pin | the pin on which you want to read a pulse |
state | type of pulse to read: either HIGH or LOW |
timeout(optional) | the number of microseconds to wait for the pulse to start; default is one second |