Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Last active August 27, 2019 10:06
Show Gist options
  • Save wmakeev/aca93bb3ae9ebc781e2a495629b970a2 to your computer and use it in GitHub Desktop.
Save wmakeev/aca93bb3ae9ebc781e2a495629b970a2 to your computer and use it in GitHub Desktop.
Arduino tips #arduino #debug #cheatsheet #tips

Show all devices

ls /dev

Dump

sudo cu -s 115200 -l /dev/tty.usbserial-1420 > ~/usbserial-1420.txt
@wmakeev
Copy link
Author

wmakeev commented Aug 27, 2019

Handle wireless button press

Hardware

Manual

Code

/*
  Simple example for receiving
  
  https://github.com/sui77/rc-switch/
*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup()
{
  Serial.begin(9600);
  mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
}

void loop()
{
  if (mySwitch.available())
  {

    Serial.print("Received ");
    Serial.print(mySwitch.getReceivedValue());

    Serial.print(" / ");

    Serial.print(mySwitch.getReceivedBitlength());
    Serial.print("bit ");

    Serial.print("Protocol: ");
    Serial.print(mySwitch.getReceivedProtocol());

    Serial.print(" Delay: ");
    Serial.print(mySwitch.getReceivedDelay());

    Serial.println();

    mySwitch.resetAvailable();
  }
}

Output

$ sudo cu -s 9600 -l /dev/tty.usbserial-1420
Password:
Connected.
Received 499570 / 24bit Protocol: 1 Delay: 320
Received 499570 / 24bit Protocol: 1 Delay: 320
Received 499570 / 24bit Protocol: 1 Delay: 325
Received 499570 / 24bit Protocol: 1 Delay: 320
Received 499570 / 24bit Protocol: 1 Delay: 320
Received 499570 / 24bit Protocol: 1 Delay: 320
Received 499570 / 24bit Protocol: 1 Delay: 321
Received 499570 / 24bit Protocol: 1 Delay: 325
Received 499570 / 24bit Protocol: 1 Delay: 321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment