Arduino board

Arduino Nano v2.3 manual (pdf)

Arduino and shift register 74HC595

74HC595 Datasheet (pdf)

74HC595 Explanation

Youtube tutorial with buttons:

Tutorial with arduino - I was using that.

My version on a breadboard:

arduino and shift register

Code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//the pins we are using
int latchPin = 2;
int clockPin = 3;
int dataPin = 4;


void setup() {
  //set all the pins used to talk to the chip
  //as output pins so we can write to them
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}
 
void loop() {
  for (int i = 0; i < 16; i++) {
 
    //take the latchPin low so the LEDs don't change while we are writing data
    digitalWrite(latchPin, LOW);
 
    //shift out the bits
    shiftOut(dataPin, clockPin, MSBFIRST, i);  
 
    //take the latch pin high so the pins reflect
    //the data we have sent
    digitalWrite(latchPin, HIGH);

    // pause before next value:
    delay(50);
  }
}

Alternatives

  • More powerful shift register: TPIC6B595
  • PWM: TLC5940, TLC5947
  • PWM with i2c: PCA9685, PCA9635

PWM via shift register

PWM Through a 74HC595 Shift Register at forum.arduino.cc

Issues with upload to Arduino Nano v3

Trying to connect to my Arduino clone (JOY-IT Arduino-compatible Nano V3 Board with ATmega328P-AU) from Ubuntu 18 I got a strange error messages.

There are three ways you can install Arduin IDE in ubuntu 18:

First of all I had to add a current user to dialout group and logout-login – that’s fine:

1
sudo usermod -a -G dialout <username>

Then all the tutorials require for checking

1
ls -l /dev/ttyACM*

And I don’t have that. I have USB0 instead:

1
2
sudo ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Jul 14 14:11 /dev/ttyUSB0

When I tried to upload some simple programms to the board I got: *

avrdude: ser_open(): can't open device "/dev/ttyUSB0": Permission denied
  • For version from sudo apt install:
arduino nano avrdude: ser_open(): can't open device "COM1": No such file or directory

That version was way too old.

  • For the version from website I got
Build options changed, rebuilding all
Sketch uses 994 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00

That was almost fine.

To fix that I had to chose Tools -> Processor -> ATmega 328P (old bootloader) instead of just “ATmega 328P”