Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ASCII
- //SPACE-32
- //UNDERSCORE-95
- // include the library code:
- #include <LiquidCrystal.h>
- #include <IRremote.h>
- IRsend irsend;
- const int joy1X = 0;
- const int joy1Y = 2;
- const int joy2X = 4;
- const int joy2Y = 6;
- // initialize the library with the numbers of the interface pins
- LiquidCrystal lcd(48, 49, 50, 51, 52, 53); //lcd(12, 11, 5, 4, 3, 2);
- int qwe;
- int gloo;
- bool monom;
- char uSc=((char)95);
- char mes[16];
- void setup() {
- qwe=0;
- gloo=0;
- monom=false;
- // set up the LCD's number of columns and rows:
- lcd.begin(16, 2);
- // Print a message to the LCD.
- Serial.begin(9600);
- pinMode(7, INPUT);
- pinMode(8, INPUT);
- pinMode(9, INPUT);
- mes[0]=uSc;
- for(int q=1; q<16; q++){
- mes[q]=(char)32;
- }
- }
- void loop() {
- lcd.clear();
- // set the cursor to column 0, line 1
- // (note: line 1 is the second row, since counting begins with 0):
- lcd.setCursor(0, 1);
- // print the number of seconds since reset:
- lcd.print(mes);
- lcd.setCursor(6,0);
- lcd.print((int)analogRead(joy1X));
- lcd.setCursor(12,0);
- lcd.print((int)analogRead(joy1Y));
- lcd.setCursor(0,0);
- lcd.write(joyType());
- //lcd.print(nunu);
- delay(200);
- gloo++;
- if(gloo%5==0){
- monom=true;
- }
- if(digitalRead(47)==HIGH){
- sendMes();
- }
- if(digitalRead(46)==HIGH){
- /*if(non==95){
- mes[qwe]=(char)32;
- }else{
- mes[qwe]=nunu;
- }*/
- mes[qwe]=joyType();
- mes[qwe+1]=uSc;
- qwe++;
- }
- /*if(digitalRead(9)==HIGH){
- mes[qwe]=' ';
- mes[qwe+1]=uSc;
- qwe++;
- }*/
- }
- int joyLX;
- int joyLY;
- int joyRX;
- int joyRY;
- int joyX;
- int joyY;
- char joyType(){
- joyY = analogRead(joy1X);
- joyX = analogRead(joy1Y);
- int horizJoy;
- int vertJoy = map(joyY, 192, 865, 2, -1);
- char joyC;
- char keyTop[] = {'q','w','e','r','t','y','u','i','o','p'};
- char keyMid[] = {'a','s','d','f','g','h','j','k','l'};
- char keyBot[] = {'z','x','c','v','b','n','m'};
- switch(vertJoy){
- case 0:
- horizJoy = map(joyX, 770, 180, 1, 10);
- joyC = keyTop[horizJoy];
- break;
- case 1:
- horizJoy = map(joyX, 770, 180, 1, 9);
- joyC = keyMid[horizJoy];
- break;
- case 2:
- horizJoy = map(joyX, 770, 180, 1, 7);
- joyC = keyBot[horizJoy];
- break;
- }
- return(joyC);
- }
- void dualJoyType(){
- joyLX = analogRead(0);
- joyLY = analogRead(1);
- joyRX = analogRead(2);
- joyRY = analogRead(3);
- //LEFT MAPPING
- int horizL;
- int vertL = map(joyLY, 200, 800, 0, 2);
- char leftC;
- char keyTopL[] = {'q','w','e','r','t'};
- char keyMidL[] = {'a','s','d','f','g'};
- char keyBotL[] = {'z','x','c','v'};
- switch(vertL){
- case 0:
- horizL = map(joyLX, 770, 180, 0, 5);
- leftC = keyTopL[horizL];
- break;
- case 1:
- horizL = map(joyLX, 770, 180, 0, 5);
- leftC = keyMidL[horizL];
- break;
- case 2:
- horizL = map(joyLX, 770, 180, 0, 4);
- leftC = keyBotL[horizL];
- break;
- }
- //RIGHT MAPPING
- int horizR;
- int vertR = map(joyRY, 192, 865, 0, 2);
- char rightC;
- char keyTopR[] = {'y','u','i','o','p'};
- char keyMidR[] = {'g','h','j','k','l'};
- char keyBotR[] = {'v','b','n','m'};
- switch(vertR){
- case 0:
- horizR = map(joyLX, 770, 180, 0, 5);
- rightC = keyTopR[horizR];
- break;
- case 1:
- horizR = map(joyLX, 770, 180, 0, 5);
- rightC = keyMidR[horizR];
- break;
- case 2:
- horizR = map(joyLX, 770, 180, 0, 4);
- rightC = keyBotR[horizR];
- break;
- }
- }
- void sendMes(){
- for(int i=0; i<16; i++){
- int msg = (int)(mes[i]);
- Serial.println(msg);
- irsend.sendSony(msg, 12);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment