Skip to content

Instantly share code, notes, and snippets.

@ttmarek
ttmarek / RedLightGreenLight.ino
Created May 2, 2014 21:22
Code that uses Arduino's timers to toggle two LED's one after the other.
// Red Light Green Light
// Hook an LED up to digital pin 9 (Red LED)
// Hoop an LED up to digital pin 7 (Green LED)
// The Red LED will blink for a second then shut off
// Once the Red LED shuts off the Green LED will turn on
void setup()
{
DDRB = (1<<PB1); // set pin 9 (Arduino UNO) as output
@ttmarek
ttmarek / FunctionGenerator.ino
Created May 2, 2014 21:24
Arduino code for generating a sine wave using Pulse Width Modulation.
#include "wavetable.h"
float seconds = 0;
int i = 0;
int num_readings = 0;
void setup()
{
Serial.begin(115200);
@ttmarek
ttmarek / arduino_wavetable_fixed.py
Created May 2, 2014 21:27
Generates a fixed amplitude wavetable for use with FunctionGenerator.ino
# Fixed Amplitude (Maximum)
import numpy as np
table = []
two_pi = 2*np.pi
res = 20
top = 500
@ttmarek
ttmarek / arduino_wavetable_variable.py
Created May 2, 2014 21:27
Generates a variable amplitude wavetable for use with FunctionGenerator.ino
# Variable Amplitude
import numpy as np
table = []
two_pi = 2*np.pi
res = 2000
top = 249
@ttmarek
ttmarek / TakeReading.ino
Created May 2, 2014 21:29
Function to send serial data to a computer, for use with FunctionGenerator.ino
/* takeReading function
* takes in an analaog pin number as an integer
* sends serial data to PC to be read by Python
*/
void takeReading(int pinNum)
{
Serial.print(seconds,4);
Serial.print(',');
Serial.println(analogRead(pinNum));
}
@ttmarek
ttmarek / arduino_serial.py
Created May 2, 2014 21:30
Python script to read serial data from the Arduino
import serial
import csv
import re
import matplotlib.pyplot as plt
import pandas as pd
portPath = "/dev/ttyACM0" # Must match value shown on Arduino IDE
baud = 115200 # Must match Arduino baud rate
timeout = 5 # Seconds
filename = "data.csv"
@ttmarek
ttmarek / running_cmake.log
Created September 28, 2015 01:30
Console output from running cmake on the Chromium Embedded Framework (cross compile Linux to Windows)
> cmake -G "Unix Makefiles" -D CMAKE_TOOLCHAIN_FILE=xcompile.cmake ..
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/i686-w64-mingw32-gcc
-- Check for working C compiler: /usr/bin/i686-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/i686-w64-mingw32-g++
-- Check for working CXX compiler: /usr/bin/i686-w64-mingw32-g++ -- works
@ttmarek
ttmarek / running_make.log
Created September 28, 2015 01:31
Console errors from running make (cross compiling CEF Linux to Windows executable)
> make -j4 cefclient cefsimple
Scanning dependencies of target libcef_dll_wrapper
Scanning dependencies of target libcef_dll_wrapper
[ 2%] [ 2%] [ 2%] Building CXX object libcef_dll/CMakeFiles/libcef_dll_wrapper.dir/base/cef_atomicops_x86_gcc.cc.obj
Building CXX object libcef_dll/CMakeFiles/libcef_dll_wrapper.dir/base/cef_bind_helpers.cc.obj
i686-w64-mingw32-g++: error: /MP: No such file or directory
i686-w64-mingw32-g++: error: /Gy: No such file or directory
i686-w64-mingw32-g++: error: /GR-: No such file or directory
i686-w64-mingw32-g++: error: /Zi: No such file or directory
i686-w64-mingw32-g++: error: /W4: No such file or directory
@ttmarek
ttmarek / xcompile.cmake
Created September 28, 2015 01:33
Cross Compile Toolchain file (CEF Linux Compile to Windows Executable)
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER /usr/bin/i686-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/i686-w64-mingw32-g++)
set(CMAKE_RC_COMPILER /usr/bin/i686-w64-mingw32-windres)
@ttmarek
ttmarek / set.js
Created March 9, 2017 04:28
A function for deeply setting values
function set(obj, path, value) {
const clone = Object.assign({}, obj);
const keys = path.split('.');
const lastKey = keys.pop();
// --------------------------------------------------
if (keys.length === 0) {
clone[lastKey] = value;
return clone;