viniciuslindoss
Published © GPL3+

Arduino HC-04 and 8x8 Matrix MAX7219

Get close and the Arduino is happy; go away and he gets sad.

BeginnerProtip14,474
Arduino HC-04 and 8x8 Matrix MAX7219

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
8x8 MAX7219 LED Matrix
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

hardware

// PIN 6 = TRIG
// PIN 5 = ECHO
// DIN = 8
// CS = 9
// CLK = 10

Code

CODE FULL

C/C++
// PIN 6 = TRIG
// PIN 5 = ECHO
// DIN = 8
// CS = 9
// CLK = 10
// MADE BY VINICIUS LOPES
#include <Ultrasonic.h>
#include "LedControl.h"
#include "binary.h"
Ultrasonic sensor (6,5);// PIN 6 = TRIG // PIN 5 = ECHO
LedControl lc = LedControl(8,10,9,1);// DIN = 8  // CS = 9 // CLK = 10

unsigned long delaytime=1000;
// PIN 6 = TRIG // PIN 5 = ECHO
// DIN = 8  // CS = 9 // CLK = 10

byte ff[8]= {
  
B00111100,
B01000010,
B10010101,
B10100001,
B10100001,
B10010101,
B01000010,
B00111100


};

byte ft[8]= {
B00111100,
B01000010,
B10100101,
B10010001,
B10010001,
B10100101,
B01000010,
B00111100};

void setup() {
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);  
}

void desenhaFaces(){


}

void loop(){
  
  int dist = sensor.Ranging(CM);
  if(dist<30){
      lc.setRow(0,0,ff[0]);
  lc.setRow(0,1,ff[1]);
  lc.setRow(0,2,ff[2]);
  lc.setRow(0,3,ff[3]);
  lc.setRow(0,4,ff[4]);
  lc.setRow(0,5,ff[5]);
  lc.setRow(0,6,ff[6]);
  lc.setRow(0,7,ff[7]);

  }else{
      lc.setRow(0,0,ft[0]);
  lc.setRow(0,1,ft[1]);
  lc.setRow(0,2,ft[2]);
  lc.setRow(0,3,ft[3]);
  lc.setRow(0,4,ft[4]);
  lc.setRow(0,5,ft[5]);
  lc.setRow(0,6,ft[6]);
  lc.setRow(0,7,ft[7]);

  }delay(100);

  
  
}

Credits

viniciuslindoss

viniciuslindoss

0 projects • 13 followers

Comments