Skip to content

Instantly share code, notes, and snippets.

View nadavmatalon's full-sized avatar

Nadav Matalon nadavmatalon

View GitHub Profile
// Must be run on Arduino.org IDE (> V1.7.11)
#include <Wire.h>
#include <ArduinoWiFi.h>
void setup() {
Wifi.begin();
Serial.begin(9600);
}
@nadavmatalon
nadavmatalon / Arduino_Assign_Default_Parm_Val.ino
Last active October 6, 2016 15:10
Arduino: Assigning Default Parameter Value
void test(int val1, int val2=2);
void setup() {
Serial.begin(9600);
test(10,11);
test(12);
}
void loop() {}

GITHUB COMMANDS

COMMAND ACTION NOTES
git init initialize a local repo
git status shows current repo status
git status -s shows current repo status: abbreviated version
git remote add remoteName remoteURL adds a remote with given name & destination URL
git remote lists all remotes
git remote -v lists all remotes & destination URLs
// Code Author: Mikal Hart
// Code Source: http://arduiniana.org/libraries/pstring/
// Direct use (no constructor):
char buffer[30];
float pi 3.14159;
PString(buffer, sizeof(buffer), pi);
// Construct an object:
char buffer[50];
// Code Author: Mikal Hart
// Code Source: http://arduiniana.org/libraries/streaming/
Serial << "Counter: " << counter;
lcd << "Temp: " << t.get_temperature() << " degrees";
my_pstring << "Hello World!" << endl;
Serial << "Byte value: " << _HEX(b) << endl;
@nadavmatalon
nadavmatalon / preprocessor_bug_fix.ino
Last active October 14, 2016 18:03
ARDUINO: Preprocessor Bug Fix
// preprocessor bug fix (place at the very top of the arduino code)
#if 1
__asm volatile ("nop");
#endif
@nadavmatalon
nadavmatalon / wswire.md
Last active October 24, 2016 19:08
WSWire
  1. I2C Communications Library

This library uses the 'WSWire' library for I2C communication between the contoller IC (Master) and the ADS1110 (Slave), so it is NECESSARY to have it installed prior to using the current libraty.

Alternatively, if you wish to use the 'Wire' - or any other I2C library for that matter - simply change the following line the the ADS1110.h file:

#include <WSWire.h>

to this:

@nadavmatalon
nadavmatalon / bitmath.cpp
Last active October 25, 2016 14:13
Bitmath Operations
// Source & much additional info:
// http://playground.arduino.cc/Code/BitMath
y = (x >> n) & 1; // n=0..7. stores nth bit of x in y. y becomes 0 or 1.
x &= ~(1 << n); // forces nth bit of x to be 0. all other bits left alone.
x &= (1<<(n+1))-1; // leaves alone the lowest n bits of x; all higher bits set to 0.
x |= (1 << n); // forces nth bit of x to be 1. all other bits left alone.
x ^= (1 << n); // toggles nth bit of x. all other bits left alone.
x = ~x; // toggles ALL the bits in x.
@nadavmatalon
nadavmatalon / update_bits.ino
Last active October 25, 2016 14:42
ARDUINO: Update Specific Bits in a Byte
byte _config = 0x00; // byte to be updated
typedef enum:byte {
MODE_MASK = 0x0C, // 12 - B00001100 (set all bits to be changed - and only them - to 1)
MODE_1 = 0x00, // 0 - B00000000 (Defualt)
MODE_2 = 0x08 // 8 - B00001000
} dev_mode_t;
void setDevMode(dev_mode_t newMode) { // PARAMS: MODE_1 / MODE_2
setConfig((_config & ~MODE_MASK) | (newMode & MODE_MASK));
@nadavmatalon
nadavmatalon / bitCode.ino
Created November 7, 2016 22:56
bitSet & bitClear: Expanded Macros
// Reference: http://stackoverflow.com/questions/16683146/can-macros-be-overloaded-by-number-of-arguments
#ifdef bitSet
#undef bitSet
#endif
#ifdef bitClear
#undef bitClear
#endif