Skip to content

Instantly share code, notes, and snippets.

View giripriyadarshan's full-sized avatar
🟥
ಕನ್ನಡಿಗ

Priyadarshan Giri giripriyadarshan

🟥
ಕನ್ನಡಿಗ
View GitHub Profile
@giripriyadarshan
giripriyadarshan / themeSwitch.js
Created March 20, 2022 05:49
switch theme using javascript and css variables (https://blog.giripriyadarshan.com/blog/20220319-1/)
const darkThemeColors = new Map([
['primary', '#68e0cf'],
['secondary', '#585d65'],
['text', '#edf8f4'],
['background', '#373b40']
]);
const lightThemeColors = new Map([
['primary', '#309485'],
['secondary', '#a7adcb'],
@giripriyadarshan
giripriyadarshan / delay_using_millis.ino
Created March 8, 2021 07:56
CPU intensive version of delay(int ms) using millis()
void msDelay(int ms)
{
unsigned long pl = millis();
while (1) // infinite loop
{
if ((millis() - pl) > ms) // if certain delay trigger
break;
}
}
@giripriyadarshan
giripriyadarshan / Debounce.cpp
Created February 8, 2021 18:53
Raspberry Pi Pico gpio_irq button debounce control for pushbuttons
#include "pico/stdlib.h"
bool state;
const uint LED_PIN = 25;
// Debounce control
unsigned long time = to_ms_since_boot(get_absolute_time());
const int delayTime = 50; // Delay for every push button may vary
@giripriyadarshan
giripriyadarshan / Debounce.ino
Created February 8, 2021 18:44
Arduino_Button_Debounce_for_interrupts
const byte led_pin = LED_BUILTIN;
const byte interrupt_pin = 2;
volatile byte state = LOW;
unsigned long interrupt_time = millis();
const unsigned long delay_time = 50; // Delay for every push button may vary
void setup() {
pinMode(led_pin, OUTPUT);
pinMode(interrupt_pin, INPUT_PULLUP);