Skip to content

Instantly share code, notes, and snippets.

@tokolist
tokolist / gist:aab4304c3aba3da0eb11ee72cc16ea7f
Last active April 12, 2024 13:38
Mikrotik stable Netwatch alternative script
:local checkHost do={
:global sendTelegramMessage;
:global hostStatuses;
:local currStatus ([/ping $host count=3] != 0);
:local message;
if ($currStatus != $hostStatuses->"$host") do={
:if ($currStatus) do={
:set ($message) "%F0%9F%86%99 $name is UP";
} else={
@tokolist
tokolist / gist:aac7562c3ed908607dec010f42d9dc88
Last active June 28, 2020 20:12
Servo control code version for Atmega 328p
#define F_CPU 16000000 //16MHz
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdlib.h>
//#include <stdio.h>
//#include "uart/uart.h"
@tokolist
tokolist / doll_hause.ino
Created February 26, 2017 20:34
Doll House Arduino
struct LedSwitch {
int buttonPin;
int ledPin;
int buttonState;
};
LedSwitch ledSwitches[] = {
{6,2,LOW},
{7,3,LOW},
{8,4,LOW},
@tokolist
tokolist / ds1302.cpp
Last active August 29, 2015 14:25
AVR ds1302 RTC library
#include "ds1302.h"
#include <avr/io.h>
#include <util/delay.h>
void ds1302_write(unsigned char cmd)
{
DS1302_CE_DDR |= (1<<DS1302_CE_PNUM);
DS1302_SCLK_DDR |= (1<<DS1302_SCLK_PNUM);
DS1302_CE_PORT |= (1<<DS1302_CE_PNUM);
@tokolist
tokolist / gist:ad8e00d3b65e6c978b01
Last active October 16, 2017 13:25
Hardware Interrupt and Seven-segment LED Digit Display Controlling Using an AVR Microcontroller http://youtu.be/XkO-7eyUWf8
#define F_CPU 16000000 //16MHz
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdlib.h>
typedef struct {
volatile uint8_t *port;
@tokolist
tokolist / gist:8319281
Last active February 11, 2020 21:26
Use an AVR Microcontroller and Potentiometer to Control a Servo (ADC and PWM) http://youtu.be/vNwx_W2daJs
#define F_CPU 16000000 //16MHz
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdlib.h>
//#include <stdio.h>
//#include "uart/uart.h"
@tokolist
tokolist / uart.cpp
Last active March 10, 2020 15:30
Simple AVR UART library
#include "uart.h"
#include <avr/io.h>
unsigned int uart_calc_ubrr(unsigned long fosc, unsigned long baud)
{
unsigned int ubrr;
unsigned long div, rem;
div = 16 * baud;
rem = fosc / div;
@tokolist
tokolist / gist:5430888
Last active October 16, 2017 13:26
AVR Microcontroller Advanced Hello World (LED Blink) http://youtu.be/KatkY_YJgsY
#define F_CPU 16000000 //16MHz
#include <avr/io.h>
#include <util/delay.h>
int ledPins[] = {PC3, PC4, PC5};
int ledPinsNum = sizeof(ledPins)/sizeof(int);
bool pressed = false;
bool oldPressed = false;
@tokolist
tokolist / gist:5387210
Last active October 16, 2017 13:27
AVR Microcontroller Hello World (LED Blink) http://youtu.be/smsW95zcFfE
#define F_CPU 1000000 //1MHz
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRC |= (1<<DDC5); // set LED pin PC5 to output
while(1)
{