Skip to content

Instantly share code, notes, and snippets.

View mithi's full-sized avatar

Mithi Sevilla mithi

View GitHub Profile
@mithi
mithi / accelReadingsThruSerial.ino
Created July 11, 2015 05:43
Arcbotics Sparki Readings Thru Serial
#include <Sparki.h>
void setup(){
}
void loop(){
Serial.print("x: ");
Serial.print(sparki.accelX());
Serial.print(",");
@mithi
mithi / melodyWithLED.ino
Created July 11, 2015 19:32
sparki singin melody with blinking lights
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
@mithi
mithi / simpleAnimations.ino
Created July 12, 2015 16:40
simple animation with Sparki's LCD
#include <Sparki.h>
class RectangleWaveAnimation{
int hNumRect;
int length;
int width;
int space;
int diffHeight;
int yCenter;
int xCenter;
@mithi
mithi / RainbowColors.ino
Created July 12, 2015 17:40
Rainbow Colors with Sparki
#include <Sparki.h>
int i;
int j;
int x;
int y;
int d;
void setup(){
j=0;
x=100;
y=10;
@mithi
mithi / jessica.py
Last active August 29, 2015 14:25
My friend jessica gave me a problem and I tried to solve it with a time complexity of o(n). You can still improve it by eliminating s_r and merging the two for loops into one but I'd rather move on to other things XD
def sol(A):
# diff = |minuend - subtrahend| or d = |m - s|
# A = [3, 1, 2, 4, 3]
l = len(A) # l = 5
m = [A[0]] # m = [3]
s = [A[l-1]] # s = [3]
s_r = [0] #reversed s
for p in range(1, l):
@mithi
mithi / servo.ino
Last active August 29, 2015 14:26
void servoNodsNo(int xTimes, int d){
for (int x = 0; x < xTimes; x++){
sparki.servo(-90);
delay(d);
sparki.servo(90);
delay(d);
}
}
@mithi
mithi / hourglass.ino
Created July 29, 2015 19:20
hourglass snippet
void hourglassHelper(int x1, int x2, int w){
sparki.moveForward(x1);
sparki.moveLeft(90);
sparki.moveForward(w);
sparki.moveLeft(90);
sparki.moveForward(x2);
sparki.moveRight(90);
@mithi
mithi / crazysun.ino
Created July 29, 2015 21:53
crazy sun snippet
void stopSignal(){
for (int x = 1; x < 10; x++){
sparki.beep();
sparki.RGB(50, 0, 100);
delay(200);
}
sparki.RGB(RGB_OFF);
}
void stopMotors(){
@mithi
mithi / IRsnippet.ino
Last active August 29, 2015 14:26
snippet of IR test
void checkIR() {
code = sparki.readIR();
previousIR == code ? code = -1: 0;
if(code != -1) {
sparki.print("Received code: ");
sparki.updateLCD();
previousIR = code;
@mithi
mithi / Sparki Cheat Sheet.md
Last active November 19, 2015 16:51
Sparki Cheat Sheet

SPARKI CHEAT SHEET

Accelerometer

sparki.accelX();
sparki.accelY();
sparki.accelZ();