Skip to content

Instantly share code, notes, and snippets.

View smetronic's full-sized avatar

Alexander Sikandar smetronic

View GitHub Profile
@smetronic
smetronic / hextoint.ino
Created December 17, 2017 11:42
ATMega 328p: Convert string hex to int
void setup() {
Serial.begin(9600);
String hexstring = "FB";
int number = (int) strtol( &hexstring[0], NULL, 16);
Serial.println(number);
}
void loop() {
@smetronic
smetronic / substring.ino
Created December 16, 2017 15:26
ATMega 328p: Read characters after keyword
void setup() {
Serial.begin(9600);
String stringValue;
String stringValue1;
String stringValue2;
stringValue = "ReadData: 1997";
@smetronic
smetronic / uid.ino
Created December 16, 2017 12:26
ATMega 328p: function to get Unique Id
#include <avr/boot.h>
void setup(void)
{
Serial.begin(9600);
Serial.println(GetUID());
}
void loop()
{
@smetronic
smetronic / sprintf.ino
Created December 16, 2017 12:21
ATMega 328p: sprintf
unsigned int i = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
char buffer[50];
sprintf(buffer, "Value: %x", i++);
Serial.println(buffer);
@smetronic
smetronic / SerialNumber.ino
Last active December 16, 2017 11:23
ATMega 328p: Unique Id/Serial Number
#include <avr/boot.h>
void print_val(char *msg, uint8_t val)
{
Serial.print(msg);
Serial.println(val, HEX);
}
void setup(void)
{
@smetronic
smetronic / Serial.ino
Created December 14, 2017 12:11
ATMega 328p: Serial Communication
#include <SoftwareSerial.h>
SoftwareSerial mySerial(13, 12); // RX, TX
void setup() {
Serial.begin(38400); //Baud Rate
mySerial.begin(38400);
}
void loop() {
@smetronic
smetronic / logic.ino
Created December 2, 2017 15:14
ATMega 328p : Analog Voltage to Serial
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
@smetronic
smetronic / main.cpp
Created November 12, 2017 14:48
Reading Serial Data using C++
#include <iostream>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <wiringPi.h>
#include <wiringSerial.h>
#include <vector>
@smetronic
smetronic / CookieConsentAttribute.cs
Created October 17, 2017 16:26 — forked from Maarten88/CookieConsentAttribute.cs
ASP.NET ActionFilterAttribute to help implement european cookie-law
/*
* ASP.NET ActionFilterAttribute to help implement EU Cookie-law
* MIT Licence (c) Maarten Sikkema, Macaw Nederland BV
*/
using System;
using System.Web;
using System.Web.Mvc;
namespace Auction.Web.Utility
<asp:Repeater ID="categoryRP" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:Label ID="Id" runat="server" Text='<%# Eval("Id") %>' />
</td>
<td>
<asp:Label ID="Name" runat="server" Text='<%# Eval("Name") %>' />
</td>
<td>