Mario Tkalac / Mbed 2 deprecated Lilnija_29012017

Dependencies:   JoystickLinija IRremote mbed Tipkalo UniServ_linijapogona umotor_linijapogona

Committer:
mario_meh
Date:
Sun Jan 29 23:23:10 2017 +0000
Revision:
0:4cac97044e74
Child:
1:055ae04a8003
Child:
2:9d19b20a60a9
Rok za predaju s. zadatka

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mario_meh 0:4cac97044e74 1 #include "mbed.h"
mario_meh 0:4cac97044e74 2 #include "IRremote.h"
mario_meh 0:4cac97044e74 3
mario_meh 0:4cac97044e74 4 Serial serial(USBTX, USBRX); // PC
mario_meh 0:4cac97044e74 5 IRrecv pinIn(PTA5); // IR
mario_meh 0:4cac97044e74 6 I2C i2c(PTC9, PTC8); // SDA, SCL
mario_meh 0:4cac97044e74 7 //Tipkalo led(PT); // LED svjetlo
mario_meh 0:4cac97044e74 8
mario_meh 0:4cac97044e74 9 const int addr = 0x0A;
mario_meh 0:4cac97044e74 10 uint8_t result[4];
mario_meh 0:4cac97044e74 11
mario_meh 0:4cac97044e74 12 int main() {
mario_meh 0:4cac97044e74 13
mario_meh 0:4cac97044e74 14 //--------------------------------------------------tipke pogona
mario_meh 0:4cac97044e74 15 //Tipkalo start = new Tipkalo(PT);
mario_meh 0:4cac97044e74 16 //Tipkalo stop = new Tipkalo(PT);
mario_meh 0:4cac97044e74 17 //Tipkalo lcd = new Tipkalo(PT);
mario_meh 0:4cac97044e74 18
mario_meh 0:4cac97044e74 19 //--------------------------------------------------IR argumenti
mario_meh 0:4cac97044e74 20 pinIn.enableIRIn(); // Start the receiver
mario_meh 0:4cac97044e74 21 decode_results results;
mario_meh 0:4cac97044e74 22
mario_meh 0:4cac97044e74 23 int IR_REMOTE = 1;
mario_meh 0:4cac97044e74 24
mario_meh 0:4cac97044e74 25 while(IR_REMOTE == 1) {
mario_meh 0:4cac97044e74 26 if (pinIn.decode(&results)) {
mario_meh 0:4cac97044e74 27 uint32_t value = results.value;
mario_meh 0:4cac97044e74 28 remote[0] = (value);
mario_meh 0:4cac97044e74 29 remote[1] = (value) >> 8;
mario_meh 0:4cac97044e74 30 remote[2] = (value) >> 16;
mario_meh 0:4cac97044e74 31 remote[3] = (value) >> 24;
mario_meh 0:4cac97044e74 32
mario_meh 0:4cac97044e74 33 i2c.write(addr,remote, 4);
mario_meh 0:4cac97044e74 34 pinIn.resume(); // Receive the next value
mario_meh 0:4cac97044e74 35 }
mario_meh 0:4cac97044e74 36 wait(0.1);
mario_meh 0:4cac97044e74 37 }
mario_meh 0:4cac97044e74 38 //-----------------------------------------------------gotov iR
mario_meh 0:4cac97044e74 39
mario_meh 0:4cac97044e74 40 //------------------------------------------isprobavam joystick
mario_meh 0:4cac97044e74 41 // Pozovi Joystick
mario_meh 0:4cac97044e74 42 Joystick *joys = new Joystick;
mario_meh 0:4cac97044e74 43 // Aktivan ručni mod
mario_meh 0:4cac97044e74 44 int LCD_SELECTED = 1;
mario_meh 0:4cac97044e74 45 //int BUTTON = 1;
mario_meh 0:4cac97044e74 46
mario_meh 0:4cac97044e74 47 while(LCD_SELECTED == 1) {
mario_meh 0:4cac97044e74 48 switch(joys->Y()) {
mario_meh 0:4cac97044e74 49 case 0:
mario_meh 0:4cac97044e74 50 serial.printf("Gore: %i\r\n", joys->Y());
mario_meh 0:4cac97044e74 51 break;
mario_meh 0:4cac97044e74 52 case 1:
mario_meh 0:4cac97044e74 53 serial.printf("Dolje: %i\r\n", joys->Y());
mario_meh 0:4cac97044e74 54 break;
mario_meh 0:4cac97044e74 55 case 4:
mario_meh 0:4cac97044e74 56 serial.printf("Odabir: %i\r\n", joys->tipka());
mario_meh 0:4cac97044e74 57 }
mario_meh 0:4cac97044e74 58 }
mario_meh 0:4cac97044e74 59 //----------------------------------------------gotov joystick
mario_meh 0:4cac97044e74 60
mario_meh 0:4cac97044e74 61 //-----------------------------------------------------svjetlo
mario_meh 0:4cac97044e74 62 //led = 1;
mario_meh 0:4cac97044e74 63 //-------------------------------------------------end svjetlo
mario_meh 0:4cac97044e74 64
mario_meh 0:4cac97044e74 65 }