Laura Duque
/
CONTROLLOCOIRDA
control loco
Revision 0:ec6950d9a18d, committed 2019-07-16
- Comitter:
- Cam53
- Date:
- Tue Jul 16 20:52:52 2019 +0000
- Commit message:
- ok
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r ec6950d9a18d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jul 16 20:52:52 2019 +0000 @@ -0,0 +1,189 @@ +/******************** ENLOQUECEDOR DE CONTROL REMOTO TV SMART HYUNDAI************************************************* +//este programa interfiere de forma loca la operacion de un televisor +//emite codigos de tv con el fin de fastidiar al televidente +/*la emision es aleatoria para + 1 mute + 2 on/off + 3 vol+ + 4 vol- + 5 canal + + 6 canal - +*/ +#include "mbed.h" +DigitalOut ledA (LED1); +DigitalOut ledR (LED2); +DigitalOut ledV (LED3); + +DigitalOut led(PTE31);//al transistor del led infrarrojo pin +int i,j; +int t; +//*********************TIEMPO PARA TELEVISOR HYUNDAI START TV**************************************** +int cabeceraL=9000; +int cabeceraH=4555; +int Tdescanso=500; +int Tlow=630; +int Thigh=1750; +int duracion; //duracion de un pulso bajo +int numb = 33; +void mute(); +void vol_up(); +void vol_dwn(); +void ch_up(); +void ch_dwn(); +void pwr(); +void repeat(); +int sendcode(int numb, int *code, int cabeceraL, int cabeceraH, int Tdescanso, int Tlow, int Thigh); +int code[65]; +int dato[65]; +int descanso(int duracion); +//const unsigned muteHY[] = {581,556,555,582,554,556,581,556,1693,1692,1692,1693,1691,1692, +// 555,1692,1694,554,1692,554,1692,554,556,581,554,1692,555,1693,554,1692,1692,1692}; +const unsigned pwr[]={1664,1663,1689,545,570,544,570,571,1663,1664,1690,546,570,543,544,570,544,1689,542,570,570,545,570,545,1689,544,1663,1662,1663,1688,1663,1662}; +const unsigned vol_up[]={1659,1662,1658,538,539,545,539,537,1687,1658,1657,540,540,536,541,538,1658,1688,1661,534,543,568,536,539,569,537,540,1658,1662,1654,1685,1685}; +const unsigned vol_dwn[]={1659,1657,1662,538,539,567,539,539,1663,1604,1658,541,541,538,541,540,1658,1659,538,1663,538,537,568,537,566,539,1660,540,1657,1660,1659,1659}; +const unsigned ch_up[]={1687,1659,1656,542,536,540,544,538,1659,1657,1661,537,540,541,538,545,538,1656,569,536,1659,536,540,542,1656,568,1654,1689,536,1661,1658,1658}; +const unsigned ch_dwn[]={1689,1662,1690,543,547,570,544,545,1664,1662,1689,570,570,544,543,571,542,571,569,544,1662,543,543,570,1662,1690,1662,1690,544,1689,1662,1689}; + +int main() { + ledA=1; + ledR=1; + ledV=1; + ledA=0; + //for(i=0;i<numb;i++){ + // code[i]=muteHY[i]; + // } + + while(1){ + + mute(); + wait(2); + mute(); + wait(2); + vol_up(); + wait(1); + vol_dwn(); + wait(1); + ch_up(); + wait(1); + ch_dwn(); + wait(1); + pwr(); + wait(5); + pwr(); + wait(3); + //sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); + //wait(5); + } +} +//la funcion descanso hace una modulacon, osea un pulso bajo por el tiempo indicado en duracion +int descanso(int duracion){ + Timer t; + t.reset(); + t.start(); + while(1) + { + led=1; + wait_us(8); + led=0; + led=0; + wait_us(9); + if(t.read_us() > duracion) return 0; + + } + } + +int sendcode(int numb, int *code, int cabeceraL, int cabeceraH, int Tdescanso, int Tlow, int Thigh) +{ + led=0; + wait_ms(100); + descanso(cabeceraL); + wait_us(cabeceraH); + + for(i=0;i<numb;i++){ + if (code[i]>1000){ + descanso(Tdescanso); + wait_us(Thigh); + } + if (code[i]<1000){ + descanso(Tdescanso); + wait_us(Tlow); + } + } + descanso(Tdescanso); + return 0; +} +//*************************rutinas estrategicas de accionar controles********************* +void vol_up(){ +for(i=0;i<numb;i++){ + code[i]=vol_upHY[i]; + } +sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); +repeat(); +for(i=0;i<15;i++){ + for(j=0;j<2;j++){ + wait_ms(56); + repeat(); + } + } +} +//********************************** +void vol_dwn(){ +for(i=0;i<numb;i++){ + code[i]=vol_dwnHY[i]; + } +sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); +repeat(); +for(i=0;i<15;i++){ + for(j=0;j<2;j++){ + wait_ms(56); + repeat(); + } + } +} +//***************************************************** +void ch_up(){ +for(i=0;i<numb;i++){ + code[i]=ch_upHY[i]; + } + for(i=0;i<30;i++){ + sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); + wait(3); + + } + +} +//********************************************************* +void ch_dwn(){ +for(i=0;i<numb;i++){ + code[i]=ch_dwnHY[i]; + } +for(i=0;i<30;i++){ +sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); + wait(3); + + } + } +//****************************************************** +void mute(){ + for(i=0;i<numb;i++){ + code[i]=muteHY[i]; + } +sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); + wait(2); +} +//********************************************************** +void pwr(){ + for(i=0;i<numb;i++){ + code[i]=pwrHY[i]; + } +sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); +} +//**************************** + +void repeat(){ + wait_ms(42); + descanso(8800); + wait_us(2240); + descanso(560); + } +//************************************************ \ No newline at end of file
diff -r 000000000000 -r ec6950d9a18d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Jul 16 20:52:52 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file