Last active
August 29, 2015 14:14
-
-
Save K-ways/cc9373aab2264ec95a16 to your computer and use it in GitHub Desktop.
Maker Winter Club
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SoftwareSerial.h> | |
SoftwareSerial BT(11, 12); | |
boolean state = 0; | |
void setup() | |
{ | |
pinMode(13, OUTPUT); | |
pinMode(2, INPUT); | |
digitalWrite(2, HIGH); | |
BT.begin(9600); | |
} | |
void loop() | |
{ | |
if(digitalRead(2) == LOW && state == 1) | |
{ | |
BT.print("0"); | |
delay(100); | |
state = 0; | |
} | |
else if (digitalRead(2) == HIGH && state == 0) | |
{ | |
BT.print("1"); | |
delay(100); | |
state = 1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SoftwareSerial.h> | |
SoftwareSerial BT(11, 12); | |
boolean state = 0; | |
void setup() | |
{ | |
BT.begin(9600); | |
Serial.begin( 9600 ); | |
pinMode( A0, INPUT ); | |
pinMode( 13, OUTPUT ); | |
} | |
void loop() | |
{ | |
int val = analogRead(A0); | |
Serial.println( val ); | |
if (val <= 1000 && state == 1) | |
{ | |
digitalWrite(13, HIGH); | |
BT.print("1"); | |
state = 0; | |
} | |
else if(val > 1000 && state == 0) | |
{ | |
digitalWrite(13, LOW); | |
state = 1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SoftwareSerial.h> | |
SoftwareSerial BT(11, 12); | |
int state = 0; | |
void setup(){ | |
Serial.begin(9600); | |
BT.begin(9600); | |
pinMode(A1, INPUT); | |
pinMode(A2, INPUT); | |
pinMode(A3, INPUT); | |
pinMode(A4, INPUT); | |
pinMode(A5, INPUT); | |
pinMode(13, OUTPUT); | |
} | |
void loop(){ | |
int preState = state; | |
int in1 = 0; | |
int in2 = 0; | |
int in3 = 0; | |
int in4 = 0; | |
int in5 = 0; | |
int maxval = 1023; | |
for(int i = 0 ; i<500 ; i++) | |
{ | |
in1 = analogRead(A1); | |
in2 = analogRead(A2); | |
in3 = analogRead(A3); | |
in4 = analogRead(A4); | |
in5 = analogRead(A5); | |
if(in1 < maxval) | |
{ | |
maxval = in1; | |
state = 1; | |
} | |
else if(in2 < maxval) | |
{ | |
maxval = in2; | |
state = 2; | |
} | |
else if(in3 < maxval) | |
{ | |
maxval = in3; | |
state = 3; | |
} | |
else if(in4 < maxval) | |
{ | |
maxval = in4; | |
state = 4; | |
} | |
else if(in5 < maxval) | |
{ | |
maxval = in5; | |
state = 5; | |
} | |
else if(950 < maxval) | |
{ | |
state = 0; | |
} | |
} | |
if(preState != state) | |
{ | |
switch(state) | |
{ | |
case 1: | |
Serial.println("1"); | |
BT.print("1"); | |
break; | |
case 2: | |
Serial.println("2"); | |
BT.print("2"); | |
break; | |
case 3: | |
Serial.println("3"); | |
BT.print("3"); | |
break; | |
case 4: | |
Serial.println("4"); | |
BT.print("4"); | |
break; | |
case 5: | |
Serial.println("5"); | |
BT.print("5"); | |
break; | |
case 0: | |
Serial.println("0"); | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() | |
{ | |
Serial.begin( 9600 ); | |
pinMode( A0, INPUT ); | |
pinMode( 13, OUTPUT ); | |
} | |
void loop() | |
{ | |
int val = analogRead(A0); | |
Serial.println( val ); | |
if (val <= 900 ) | |
{ | |
digitalWrite(13, HIGH); | |
} | |
else | |
{ | |
digitalWrite(13, LOW); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <MaxMatrix.h> | |
#include <avr/pgmspace.h> | |
#include <SoftwareSerial.h> | |
SoftwareSerial BT(11, 12); | |
PROGMEM prog_uchar CH[] = { | |
3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space | |
1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // ! | |
3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // " | |
5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // # | |
4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $ | |
5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // % | |
5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // & | |
1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // ' | |
3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // ( | |
3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // ) | |
5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // * | |
5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // + | |
2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // , | |
4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // - | |
2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // . | |
4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // / | |
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0 | |
3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1 | |
4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2 | |
4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3 | |
4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4 | |
4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5 | |
4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6 | |
4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7 | |
4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8 | |
4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9 | |
2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // : | |
2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ; | |
3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // < | |
3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // = | |
3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // > | |
4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ? | |
5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @ | |
4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A | |
4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B | |
4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C | |
4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D | |
4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E | |
4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F | |
4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G | |
4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H | |
3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I | |
4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J | |
4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K | |
4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L | |
5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M | |
5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N | |
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O | |
4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P | |
4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q | |
4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R | |
4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S | |
5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T | |
4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U | |
5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V | |
5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W | |
5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X | |
5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y | |
4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z | |
2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [ | |
4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash | |
2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ] | |
3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat | |
4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _ | |
2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // ` | |
4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a | |
4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b | |
4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c | |
4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d | |
4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e | |
3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f | |
4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g | |
4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h | |
3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i | |
4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j | |
4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k | |
3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l | |
5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m | |
4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n | |
4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o | |
4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p | |
4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q | |
4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r | |
4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s | |
3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t | |
4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u | |
5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v | |
5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w | |
5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x | |
4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y | |
3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z | |
3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // { | |
1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // | | |
3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // } | |
4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~ | |
}; | |
PROGMEM prog_uchar PICTURES[] = { | |
8, 8, B11111111, B10000001, B10111101, B10100101, B10100101, B10111101, B10000001, B11111111, //picture1 | |
8, 8, B11111111, B10000001, B10000001, B10000001, B10000001, B10000001, B10000001, B11111111, | |
8, 8, B11111111, B10000001, B10111101, B10111101, B10111101, B10111101, B10000001, B11111111, | |
8, 8, B11111111, B10000001, B11111111, B10100101, B10100101, B11111111, B10000001, B11111111, | |
}; | |
int data = 8; // DIN pin of MAX7219 module | |
int load = 9; // CS pin of MAX7219 module | |
int clock = 10; // CLK pin of MAX7219 module | |
int maxInUse = 2; //change this variable to set how many MAX7219's you'll use | |
MaxMatrix m(data, load, clock, maxInUse); // define module | |
byte buffer[100]; | |
// active sentenses | |
char string1[] = " NCC x Dr.maker "; | |
// just for tests | |
char string7[] = " A B C D E F G H I J K L M N O P Q R S T U V X W Y Z "; | |
char string8[] = " a b c d e f g h i j k l m n o p q r s t u v x w y z "; | |
char string9[] = " 1 2 3 4 5 6 7 8 9 0 - = "; | |
char string10[] = " ! @ # $ % ¨ & * ( ) _ + "; | |
char string11[] = " ' , . ; ~ ] ´ [ | < > : ^ } ` { / ? "; | |
//Picture | |
char pic1[] = "1"; | |
char pic2[] = "2"; | |
char pic3[] = "3"; | |
char pic4[] = "4"; | |
int val; | |
void setup(){ | |
m.init(); // module initialize | |
m.setIntensity(5); // dot matix intensity 0-15 | |
Serial.begin(9600); // serial communication initialize | |
BT.begin(9600); | |
} | |
void loop(){ | |
if(BT.available()) | |
{ | |
val = BT.read(); | |
} | |
switch (val) | |
{ | |
case '1': | |
printPIC(pic1); | |
break; | |
case '2': | |
printPIC(pic2); | |
break; | |
case '3': | |
printPIC(pic3); | |
break; | |
case '4': | |
printPIC(pic4); | |
break; | |
} | |
} | |
void printCharWithShift(char c, int shift_speed){ | |
if (c < 32) return; | |
c -= 32; | |
memcpy_P(buffer, CH + 7*c, 7); | |
m.writeSprite(32, 0, buffer); | |
m.setColumn(32 + buffer[0], 0); | |
for (int i=0; i<buffer[0]+1; i++) | |
{ | |
delay(shift_speed); | |
m.shiftLeft(false, false); | |
} | |
} | |
void printStringWithShift(char* s, int shift_speed){ | |
while (*s != 0){ | |
printCharWithShift(*s, shift_speed); | |
s++; | |
} | |
} | |
void printString(char* s) | |
{ | |
int col = 0; | |
while (*s != 0) | |
{ | |
if (*s < 32) continue; | |
char c = *s - 32; | |
memcpy_P(buffer, CH + 7*c, 7); | |
m.writeSprite(col, 0, buffer); | |
m.setColumn(col + buffer[0], 0); | |
col += buffer[0] + 1; | |
s++; | |
} | |
} | |
void printPIC(char* s) | |
{ | |
int col = 0; | |
while (*s != 0) | |
{ | |
if (*s < 32) continue; | |
char c = *s - 49; | |
memcpy_P(buffer, PICTURES + 10*c, 10); | |
m.writeSprite(col, 0, buffer); | |
m.setColumn(col + buffer[0], 0); | |
col += buffer[0]; | |
s++; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SoftwareSerial.h> | |
SoftwareSerial BT(11, 12); | |
int val = 0; | |
void setup() | |
{ | |
pinMode(13, OUTPUT); | |
BT.begin(9600); | |
} | |
void loop() | |
{ | |
if(BT.available()) | |
{ | |
val = BT.read(); | |
} | |
switch (val) | |
{ | |
case '0': | |
digitalWrite(13, 0); | |
break; | |
case '1': | |
digitalWrite(13, 1); | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SoftwareSerial.h> | |
SoftwareSerial BT(11, 12); // RX & TX | |
void setup() | |
{ | |
BT.begin(38400); | |
Serial.begin(9600); | |
Serial.println("Enter commands:"); | |
} | |
void loop() | |
{ | |
if (BT.available()) | |
{ | |
char data = BT.read(); | |
Serial.print(data); | |
} | |
if (Serial.available()) | |
BT.write(Serial.read()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment