Skip to content

Instantly share code, notes, and snippets.

@elktros
elktros / ESP8266-I2C-LCD-Demo.ino
Created February 24, 2021 16:04
Display text on I2C LCD using ESP8266 NodeMCU.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 16, 2);
void setup()
{
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
@elktros
elktros / Raspberry_Pi_TCS3200_Color_Detector.py
Created February 12, 2018 11:36
Python Script for Raspberry Pi based Color Detector using TCS3200 Color Sensor.
import RPi.GPIO as GPIO
import time
s2 = 23
s3 = 24
signal = 25
NUM_CYCLES = 10
@elktros
elktros / ESP8266-NodeMCU-OLED-Text.ino
Created February 26, 2021 07:47
Display text on OLED using ESP8266 NodeMCU.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_MOSI 13
#define OLED_CLK 14
@elktros
elktros / Arduino_Water_Flow_Sensor.ino
Created June 18, 2018 10:48
Code for interfacing YF-S201 Water Flow Sensor with Arduino UNO.
const int watermeterPin = 2;
volatile int pulse_frequency;
unsigned int literperhour;
unsigned long currentTime, loopTime;
byte sensorInterrupt = 0;
void setup()
{
pinMode(watermeterPin, INPUT);
@elktros
elktros / 8051_7_Segment_Interface_4_Digit.c
Last active May 2, 2024 11:27
Code for interfacing 4-digit 7-segment display with 8051 Microcontroller. The display type is Common Anode.
#include<reg51.h>
#define led P0
sbit sw1=P2^0;
sbit sw2=P2^1;
sbit sw3=P2^2;
sbit sw4=P2^3;
unsigned char ch[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
//void delay (int);
void display (unsigned long int);
void sdelay (char);
@elktros
elktros / ISD1820_Voice_Recorder_Arduino.ino
Created December 26, 2018 10:18
Code for Interfacing ISD1820 Voice Recorder Module with Arduino.
int rec=2;
int play=3;
int sensor=4;
int led=13;
void setup()
{
pinMode(rec,OUTPUT);
pinMode(play,OUTPUT);
pinMode(led,OUTPUT);
@elktros
elktros / Arduino_Interrupts_Button_Interrupt_Debounce.ino
Created June 29, 2018 08:04
Interrupt based Button sketch with debounce for Arduino Interrupts Tutorial.
int ledPin = 13;
int buttonPin = 2;
int ledToggle;
int previousState = HIGH;
unsigned int previousPress;
volatile int buttonFlag;
int buttonDebounce = 20;
void setup()
@elktros
elktros / Digital_Voltmeter_using_8051_VoltageSensor_ADC0804.c
Created November 14, 2018 04:29
Code for Digital Voltmeter using 8051 Microcontroller, Voltage Sensor and ADC0804.
#include<reg51.h>
#define lcd P3
#define dat P2
sbit rs=P1^6;
sbit e=P1^7;
void delay (int);
void display (unsigned char);
void cmd (unsigned char);
int Lane1[] = {13,12,11}; // Lane 1 Red, Yellow and Green
int Lane2[] = {10,9,8};// Lane 2 Red, Yellow and Green
int Lane3[] = {7,6,5};// Lane 3 Red, Yellow and Green
int Lane4[] = {4,3,2};// Lane 4 Red, Yellow and Green
void setup()
{
for (int i = 0; i < 3; i++)
{
pinMode(Lane1[i], OUTPUT);
@elktros
elktros / Arduino_DS3231_RTC_Tutorial.ino
Created August 29, 2018 07:11
Code for interfacing DS3231 RTC (Real Time Clock) Module with Arduino.
#include <Wire.h>
#include <LiquidCrystal.h>
#include "RTClib.h"
DateTime now;
char daysOfTheWeek[7][12] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
RTC_DS3231 rtc;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // (rs, e, d4, d5, d6, d7)