Skip to content

Instantly share code, notes, and snippets.

@cousteaulecommandant
Created January 10, 2017 19:50
Show Gist options
  • Save cousteaulecommandant/3083c33cc83497d05e1fa12ae8cfaf17 to your computer and use it in GitHub Desktop.
Save cousteaulecommandant/3083c33cc83497d05e1fa12ae8cfaf17 to your computer and use it in GitHub Desktop.
struct MyPrintable : Printable {
const char *p;
MyPrintable(const char *p) : p(p) {}
size_t printTo(Print &P) const {int i; for (i=0; p[i]; i++) P.write(p[i]); return i;}
};
void setup() {
#define FSH F("Flash string")
String S("String");
char arr[] = "char array";
char c = 'c';
unsigned char uc = 42;
int i = 42;
unsigned int ui = 0x42;
long L = 042;
unsigned long uL = 0b00101010;
double d = 42.0;
MyPrintable P("Printable");
Serial.begin(9600);
Serial.println(FSH); // FlashStringHelper
Serial.println(S); // String
Serial.println(S+S); // StringSumHelper
Serial.println(arr); // const char *
Serial.println(c); // char
Serial.println(uc ); // unsigned char }
Serial.println(i, DEC); // int }
Serial.println(ui, HEX); // unsigned int } numbers
Serial.println(L, OCT); // long }
Serial.println(uL, BIN); // unsigned long }
Serial.println(d); // double
Serial.println(P); // Printable
}
void loop() { }
void setup() {
Serial.begin(9600);
Serial.print(3);
Serial.println(" shall be the number thou shalt count,");
Serial.print("and the number of the counting shall be ");
Serial.println(3);
}
void loop() { }
void setup() {
Serial.begin(9600);
Serial.println("1");
Serial.println("2");
Serial.println("3");
Serial.println("4");
Serial.println("5");
Serial.println("6");
Serial.println("7");
Serial.println("8");
Serial.println("9");
Serial.println("10");
}
void loop() { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment