Skip to content

Instantly share code, notes, and snippets.

@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)
@elktros
elktros / ESP32-I2C-LCD-Text.ino
Created February 27, 2021 08:34
Interface PCF8574 I2C LCD with ESP32.
#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 / blinkingLED.asm
Last active November 2, 2023 14:01
8051 Microcontroller Assembly Language Program for Blinking LEDs
ORG 00H ; Assembly Starts from 0000H.
; Main Program
START: MOV P1, #0XFF ; Move 11111111 to PORT1.
CALL WAIT ; Call WAIT
MOV A, P1 ; Move P1 value to ACC
CPL A ; Complement ACC
MOV P1, A ; Move ACC value to P1
CALL WAIT ; Call WAIT
SJMP START ; Jump to START
WAIT: MOV R2, #10 ; Load Register R2 with 10 (0x0A)
@elktros
elktros / ESP8266_WiFi_Controlled_Relay_Android.ino
Created April 4, 2018 10:40
Code for ESP8266 WiFi Module for Controlling a Relay over WiFi using Android App developed withe the help of MIT App Inventor 2.
#include <ESP8266WiFi.h>
const char* ssid = "SSID";//type your ssid
const char* password = "PASSWORD";//type your password
int relayPin = 2; // GPIO2 of ESP8266
WiFiServer ESPserver(80);//Service Port
void setup()
{
@elktros
elktros / Arduino_Radar_Processing_Code.pde
Created June 14, 2018 06:36
Processing Code for Arduino Radar Project.
import processing.serial.*;
import processing.opengl.*;
import toxi.geom.*;
import toxi.processing.*;
ToxiclibsSupport gfx;
Serial port;
String serialAngle;