FD1642-CT1642-SM1642-ET6227

FD1642-CT1642-SM1642-ET6227

In this Arduino Tutorial we will learn how
Usage of an 18Bit shift register found in the front panels of
various household electronic appliances ( such as set-top boxes, DVD players or various other LED display devices).                   

Schema




download






Code: Download

Library


// REQUIRES the following Arduino libraries:
// - CT1642 library: https://github.com/arkroan/CT1642
// - RTC DS1307 Library: https://github.com/MajicDesigns/MD_DS1307
// - IRremote library can be found at https://github.com/z3t0/Arduino-IRremote
// Find All "Great Projects" Videos : https://www.youtube.com/channel/UCCC8DuqicBtP3A_aC53HYDQ/videos

Code

// REQUIRES the following Arduino libraries:
// - CT1642 library: https://github.com/arkroan/CT1642
// - RTC DS1307 Library: https://github.com/MajicDesigns/MD_DS1307
// - IRremote library can be found at https://github.com/z3t0/Arduino-IRremote
// Find All "Great Projects" Videos : https://www.youtube.com/channel/UCCC8DuqicBtP3A_aC53HYDQ/videos

#include <CT1642.h>
#include <time.h>
#include <SPI.h>
#include <IRremote.h>
#define USE_DS1307 0
#include <MD_DS1307.h>
#include <Wire.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

#define CLOCK_PIN 6
#define DATA_PIN 7
CT1642 ledDisplay(CLOCK_PIN, DATA_PIN);

uint32_t lastTime = 0; // millis() memory
bool flasher = false; // seconds passing flasher
uint16_t hours, minutes, second, day, month, year;
int mm1, mm2, d1, d2;
int h1, h2, m1, m2;
int y1, y2, y3, y4;
int s1, s2;
int mode = 0;

void getTime(){
RTC.readTime();
minutes = RTC.m;
hours = RTC.h;
h1 = hours / 10;
hours = hours - (h1 * 10);
h2 = hours;
m1 = minutes / 10;
minutes = minutes - (m1 * 10);
m2 = minutes;
}
void getSec(){
RTC.readTime();
second = RTC.s;
s1 = second / 10;
second = second - (s1 * 10);
s2 = second;
}
void getDate(){
RTC.readTime();
month = RTC.mm;
day = RTC.dd;
mm1 = month / 10;
month = month - (mm1 * 10);
mm2 = month;
d1 = day / 10;
day = day - (d1 * 10);
d2 = day;
}
void getYear(){
RTC.readTime();
year = RTC.yyyy;
y1 = year / 1000;
year = year - (y1 * 1000);
y2 = year / 100;
year = year - (y2 * 100);
y3 = year / 10;
year = year - (y3 * 10);
y4 = year;
}
void getresultIR(){
if (irrecv.decode(&results)) {
if (results.value==0x38863BDC){
mode++;
if (mode >= 4 ) {
mode = 0;
}
} else if (results.value==0x38863BF2){
if (mode == 1 ) {
RTC.s = 0;
RTC.writeTime();
}
else if (mode == 4 ) {
RTC.m++;
if (RTC.m >= 60 ) {
RTC.m = 0;
}
RTC.writeTime();
}
else if (mode == 5 ) {
RTC.h++;
if (RTC.h >= 24 ) {
RTC.h = 0;
}
RTC.writeTime();
}
else if (mode == 6 ) {
RTC.dd++;
if (RTC.dd >= 32 ) {
RTC.dd = 1;
}
RTC.writeTime();
}
else if (mode == 7 ) {
RTC.mm++;
if (RTC.mm >= 13 ) {
RTC.mm = 1;
}
RTC.writeTime();
}
else if (mode == 8 ) {
RTC.yyyy++;
if (RTC.yyyy >= 2041 ) {
RTC.yyyy = 2001;
}
RTC.writeTime();
}
} else if (results.value==0x38863BFA){
if (mode <= 3 ) {
mode = 0;
}
else if (mode == 4 ) {
RTC.m--;
if (RTC.m <= 0 ) {
RTC.m = 59;
}
RTC.writeTime();
}
else if (mode == 5 ) {
RTC.h--;
if (RTC.h <= 0 ) {
RTC.h = 23;
}
RTC.writeTime();
}
else if (mode == 6 ) {
RTC.dd--;
if (RTC.dd <= 0 ) {
RTC.dd = 31;
}
RTC.writeTime();
}
else if (mode == 7 ) {
RTC.mm--;
if (RTC.mm <= 0 ) {
RTC.mm = 12;
}
RTC.writeTime();
}
else if (mode == 8 ) {
RTC.yyyy--;
if (RTC.yyyy <= 2000 ) {
RTC.yyyy = 2041;
}
RTC.writeTime();
}
} else if (results.value==0x38863BC2){
mode++;
if (mode >= 9 || mode <= 4) {
mode = 4;
}
} else if (results.value==0x38863BCA){
mode--;
if (mode <= 3) {
mode = 8;
}
}
irrecv.resume(); // Receive the next value
}
}
void setup() {
irrecv.enableIRIn(); // Start the receiver
RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);
RTC.control(DS1307_12H, DS1307_OFF);
RTC.readTime();
}

void loop() {
getresultIR();
if (mode == 0) {
if (millis() - lastTime >= 1000)
{
lastTime = millis();
getTime();
flasher = !flasher;
}
if (flasher) {
ledDisplay.showChars(' ', 3);
}
ledDisplay.showSingle(h1, 4);
ledDisplay.showSingle(h2, 3);
ledDisplay.showSingle(m1, 2);
ledDisplay.showSingle(m2, 1);
}
else if (mode == 1) {
if (millis() - lastTime >= 1000)
{
lastTime = millis();
getSec();
flasher = !flasher;
}
if (flasher) {
ledDisplay.showChars(' ', 3);
}
ledDisplay.showSingle(s1, 2);
ledDisplay.showSingle(s2, 1);
}
else if (mode == 2) {
getDate();
ledDisplay.showSingle(d2, 1);
ledDisplay.showSingle(d1, 2);
ledDisplay.showSingle(mm2, 3);
if (mm1 == 0) {
ledDisplay.showChars('0', 4);
}else
ledDisplay.showSingle(mm1, 4);
}
else if (mode == 3) {
getYear();
ledDisplay.showChars(' ', 1);
ledDisplay.showSingle(y1, 4);
ledDisplay.showSingle(y2, 3);
ledDisplay.showSingle(y3, 2);
ledDisplay.showSingle(y4, 1);
}
else if (mode == 4) {
if (millis() - lastTime >= 300)
{
lastTime = millis();
getTime();
flasher = !flasher;
}
if (flasher)
{
ledDisplay.showChars(' ', 3);
ledDisplay.showSingle(h1, 4);
ledDisplay.showSingle(h2, 3);
ledDisplay.showSingle(m1, 2);
ledDisplay.showSingle(m2, 1);
} else
ledDisplay.showSingle(h1, 4);
ledDisplay.showSingle(h2, 3);
}
else if (mode == 5) {
if (millis() - lastTime >= 300)
{
lastTime = millis();
getTime();
flasher = !flasher;
}
if (flasher)
{
ledDisplay.showChars(' ', 3);
ledDisplay.showSingle(h1, 4);
ledDisplay.showSingle(h2, 3);
ledDisplay.showSingle(m1, 2);
ledDisplay.showSingle(m2, 1);
} else
ledDisplay.showSingle(m1, 2);
ledDisplay.showSingle(m2, 1);
}
else if (mode == 6) {
if (millis() - lastTime >= 300)
{
lastTime = millis();
getDate();
flasher = !flasher;
}
if (flasher)
{
ledDisplay.showSingle(d2, 1);
ledDisplay.showSingle(d1, 2);
ledDisplay.showSingle(mm2, 3);
if (mm1 == 0) {
ledDisplay.showChars('0', 4);
}else
ledDisplay.showSingle(mm1, 4);
} else
ledDisplay.showChars(' ', 1);
ledDisplay.showSingle(mm2, 3);
if (mm1 == 0) {
ledDisplay.showChars('0', 4);
}else
ledDisplay.showSingle(mm1, 4);
}
else if (mode == 7) {
if (millis() - lastTime >= 300)
{
lastTime = millis();
getDate();
flasher = !flasher;
}
if (flasher)
{
ledDisplay.showSingle(d2, 1);
ledDisplay.showSingle(d1, 2);
ledDisplay.showSingle(mm2, 3);
if (mm1 == 0) {
ledDisplay.showChars('0', 4);
}else
ledDisplay.showSingle(mm1, 4);
} else
ledDisplay.showChars(' ', 1);
ledDisplay.showSingle(d1, 2);
ledDisplay.showSingle(d2, 1);
}
else if (mode == 8) {
if (millis() - lastTime >= 300)
{
lastTime = millis();
getYear();
getYear();
flasher = !flasher;
}
if (flasher)
{
ledDisplay.showSingle(y1, 4);
ledDisplay.showSingle(y2, 3);
ledDisplay.showSingle(y3, 2);
ledDisplay.showSingle(y4, 1);
} else
ledDisplay.showChars(' ', 1);
}
}

text


void showChars(char char1, int digit);


void CT1642::showChars(char char1, int digit){

write(getCharByte(char1)|DATA_DOT, digit);
delay(povDelay);
}

ESP8266 ultrasonic distance measuring Displayed on MAX7219 Dot Matrix

ESP8266 ultrasonic distance measuring Displayed on MAX7219 Dot Matrix

In this Arduino Tutorial we will learn how the HC-SR04 Ultrasonic Sensor works and how to use it with the Arduino Board. You can watch the following video or read the written tutorial below.
The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the esp8266

Schema



download

ESP8266 ESP-12F WIFI Development Board


Ultrasonic Module HC-SR04 Distance Measuring Ranging Transducer Sensor

Ultrasonic Module HC-SR04 Distance Measuring
https://www.banggood.com/custlink/KmDD799F7I
ESP8266 ESP-12F WIFI Development Board
https://www.banggood.com/custlink/3G33WYMqOm
MAX7219 Dot Matrix Module 4-in-1 LED Display Module
https://www.banggood.com/custlink/vKvKuS8VwE


Code: Download

Library

// REQUIRES the following Arduino libraries:
// - HCSR04 library: https://github.com/Martinsos/arduino-lib-hc-sr04
// - MD_Parola Library: https://github.com/MajicDesigns/MD_Parola
// - MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
// Find All "Great Projects" Videos : https://www.youtube.com/channel/UCCC8DuqicBtP3A_aC53HYDQ/videos

Code

// - REQUIRES the following Arduino libraries:
// - MD_Parola Library: https://github.com/MajicDesigns/MD_Parola
// - MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
// - HCSR04 library: https://github.com/Martinsos/arduino-lib-hc-sr04
// - More videos : https://www.youtube.com/channel/UCCC8DuqicBtP3A_aC53HYDQ/videos

// includes

#include <ESP8266WiFi.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <HCSR04.h>
UltraSonicDistanceSensor distanceSensor(12, 4); // Initialize sensor that uses digital pins 13 and 12.
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 3

#define CLK_PIN 14 // or SCK
#define DATA_PIN 13 // or MOSI
#define CS_PIN 15 // or SS

// SPI hardware interface
//MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

char ssid[] = "Verus"; // your network SSID (name)
char pass[] = "Bou3bou3@.com"; // your network password
bool newDistance = false;
int distance;
char szTime[9];

void readDistance() {
distance = distanceSensor.measureDistanceCm();
newDistance = true;
delay(300);
}
void setup() {
P.begin(1);
P.setZone(0, 0, 2);
P.displayZoneText(0, szTime, PA_CENTER, 25, 0, PA_PRINT, PA_NO_EFFECT);
}

void loop() {
readDistance();
P.displayAnimate();
P.getZoneStatus(0);
if (newDistance)
{
sprintf(szTime, "%d", distance);
P.displayReset(0);
newDistance = false;
}
}