themactep

a collection of miscellaneous projects of Paul Philippov

Maximum values for fixed data types

  • uint8_t – 255
  • uint16_t – 65,535
  • uint32_t – 4,294,967,295
  • uint64_t – 18,446,744,073,709,551,615

How to use Arduino watchdog

#include <avr/wdt.h>

void setup() {
  wdt_enable(WDTO_2S);
  //...
}

void loop() {
  wdt_reset();
  //...
}

How to use interrupts

Interrupt pins

Interrupt 0 1 2 3 4  
Uno 2 3        
Mega 2560 2 3 21 20 19 18
Leonardo 3 2 0 1 7  
void setup() {
  attachInterrupt(1, doSomething, CHANGE); // LOW|CHANGE|RISING|FALLING|HIGH
}

void loop() {  
  // ...
}

void doSomething() {
  // ...
}

How to avoid conflicts uploading sketches to Arduino Leonardo boards

Get rid of modemmanager package.

$ sudo apt-get remove modemmanager

TinkerKit! 16x2 Text LCD Module Shield

A0 connector

Connector 1 2 3
Board pin   18  
Signal VCC   GND

A1 connector

Connector 1 2 3
Board pin   19  
Signal VCC   GND

A2 connector

Connector 1 2 3
Board pin   20  
Signal VCC   GND

D5 connector

Connector 1 2 3
Board pin   5  
Signal VCC   GND

D6 connector

Connector 1 2 3
Board pin   6  
Signal VCC   GND

D11 (D12) connector

Connector 1 2 3
Board pin   11  
Signal VCC   GND

Serial connector

Connector 1 2 3 4
Board pin 1 0    
Signal TX RX VCC GND

TWI1 connector

Connector 1 2 3 4
Board pin 3 2    
Signal SCL SDA VCC GND

TWI2 connector

Connector 1 2 3 4
Board pin 3 2    
Signal SCL SDA VCC GND

ICSP connector

Connector 1 2 3 4 5 6
Board pin 14 5V 15 16    
Signal MISO VCC SCK MOSI RST GND

Display connector

Display pin VSS VDD V0 RS RW E D0 D1 D2 D3 D4 D5 D6 D7 BL+ BL-
Connector 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Board pin GND 5V 27/9 22 23 7 - - - - 21 24/4 29/12 26/8 5V GND

Side connector

Connector 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Board pin GND 5V 27/9 22 23 7 - - - - 21 24/4 29/12 26/8