Skip to content

Instantly share code, notes, and snippets.

@SammyOina
SammyOina / ReadDisplay.asm
Created October 12, 2021 21:50
Receives input data through pins in PORTD and does a NAND operation on the input. The results of the NAND operation are written to PORTB.
;
; ReadDisplay.asm
;
; Created: 10/13/2021 12:09:07 AM
; Author : sammy oina kerata
;
setup:
ldi r17, 0b00000000
out ddrd, r17
@SammyOina
SammyOina / CountsUp.asm
Created October 12, 2021 21:53
Counts up to 249 and sends the number count to PORTC. Upon reaching 249, it should reset to 5 and again count up to 249. After 249 it should reset to 0 and repeat the whole process again. AVR assembly code (328p)
;
; CountsUp.asm
;
; Created: 10/11/2021 11:07:36 PM
; Author : sammy Kerata Oina
;
setup:
ldi r17, 0b11111111
@SammyOina
SammyOina / fan temperature control.ino
Last active February 24, 2022 13:31
simple pid controlled fan with encoder
/* Sammy Oina Kerata
* ENM221-0089/2017
* fan speed control with temprature with encoder
*/
float revCounts=0; //revolutions counted
float motorSpeed=0; //current motor speed
unsigned long prevTime = 0; //previous time used to calculate
float speedFreq=0; //motor speed in HZ
float kp = 3.4; //proportional gain of the motor control
float kd = 34; //derivative gain
@SammyOina
SammyOina / intro.ino
Last active March 17, 2022 17:45
intro to free rtos gdsc
int button = 5;
void setup()
//Initialize the Serial Monitor with 9600 baud rate
{
Serial.begin(9600);
Serial.println(F("In Setup function"));
//Set the digital pins 8 to 11 as digital output pins
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
@SammyOina
SammyOina / dojo1.ino
Last active September 13, 2022 15:44
#include <Servo.h>
#include <hcsr04.h>
Servo frontServo;
Servo backServo;
#define TRIG1 4
#define TRIG2 5
#define ECHO1 6
#define ECHO2 7
int ENA = 12; //Left motor
@SammyOina
SammyOina / README.MD
Created May 16, 2023 09:35
Using empty structs as context keys

Using empty structs as context keys

It is common to use integer types as keys in maps due low memeory allocation leading to better performance. For example int8 occupies a single byte of memory. An empty struct in golang have a minimum size of zero bytes, but they may have a size greater than zero due to padding. The size of an empty struct in Go is implementation-dependent, and it is usually 1 byte or larger to ensure that each instance of a struct has a unique memory address.

package main

import (