collapse

* Links de Robótica

* Posts Recentes

Recomendação de um opamp para um DAC r2r por jm_araujo
[Ontem às 10:48]


Feira de electricidade e eletrónica por beirao
[Ontem às 00:32]


RN42 e TP-Link MR3020 por doiga
[22 de Novembro de 2017, 19:22]


Ajuda Projecto IR / RF por senso
[22 de Novembro de 2017, 13:15]


Ideias para construir um quadrúpede simples por dropes
[21 de Novembro de 2017, 22:43]


Ajuda com TRIAC por senso
[17 de Novembro de 2017, 18:00]


TV LG White Screen por almamater
[15 de Novembro de 2017, 08:37]


Pergunta sobre prototipagem ( Pesquisa ) por luisjustin
[14 de Novembro de 2017, 23:22]


Medir Agua que está no Poço por Njay
[14 de Novembro de 2017, 13:28]


Amplificador audio por beirao
[12 de Novembro de 2017, 23:43]

Autor Tópico: Projecto Cesário (irremote, d. movimento, 595's, 4051's, LDR, s.temp, etc...)  (Lida 1439 vezes)

0 Membros e 1 Visitante estão a ver este tópico.

Donvan

  • Visitante
Três register’s 595
 Out -  register/nº pin - ligado a
o0                1/0                     Relê 1 (som 2.1)
o1                1/1                Led RGB1 (blue)
o2                1/2                Led RGB1 (red)
o3                1/3                Relê 2 (candeeiro(luz))
o4                1/4                Led’s verde botão box
o5                1/5                Led indicador verde box
o6                1/6                Led indicador azul box
o7                1/7                Led indicador vermelho box
o8                2/0                Relê 3 (som subwoofer)
o9                2/1                (com transístor) Ventilador box
o10                2/2                (com transístor) 2 Led’s branco 10mm altobrilho
o11                2/3                (com transístor tip120) tubo de leds azul
o12                2/4                (com transístor tip120) strobe
o13                2/5                (com transístor tip120) néon raios
o14                2/6                (com transístor tip120) néon uv
o15                2/7                RGB1 (green)
o16                3/0                Relê 4 (foco dimmer(luz))
o17                3/1                Relê 5 (vazio)
o18                3/2                RGB2 (red)
o19                3/3                RGB2 (green)
o20                3/4                RGB2 (blue)
o21                3/5                RGB3 (red)
o22                3/6                RGB3 (green)
o23                3/7                RGB3 (blue)

1 multiplex 4051
in  -     ligado a
i0                vazio (ligado a gnd)
i1                sensor temperatura 2
i2                sensor temperatura 1
i3                LDR
i4                botão ‘power’ box
i5                botão ‘menu/ok’ 3.3v/5v
i6                botão ‘esq./dir.’ 3.3v/5v
i7                botão ‘cima/baixo’ 3.3v/5v


1 desmultiplex 4051
Out       -   ligado a
0                     Leddisplay4x7 catodo segmento (a)
1                Leddisplay4x7 catodo segmento (b)
2                Leddisplay4x7 catodo segmento (c)
3                Leddisplay4x7 catodo segmento (d)
4                Leddisplay4x7 catodo segmento (e)
5                Leddisplay4x7 catodo segmento (f)
6                Leddisplay4x7 catodo segmento (g)
7                Leddisplay4x7 catodo segmento (2 pontos)
Z                GND

Arduino
A0   Z do multiplex 4051 (Ain)
A1   vazio
A2   vazio
A3   vazio
A4   detector de movimento (Digitalin)
A5   IrRemote2 (Din)
0   vazio
1   vazio
2   IrRemote 1 (Din)
3~   Leddisplay4x7 digito 1 (out)
4   S0 des/multiplex 4051
5~   Leddisplay4x7 digito 2 (out)
6~   Leddisplay4x7 digito 3 (out)
7   S1 des/multiplex 4051
8   LatchPin
9~   Leddisplay4x7 digito 4 (out)
10~   Enable desmultiplex 4051 (leddisplay4x7) LOW para display ON
11~   DataPin
12   Clockpin
13   S2 des/multiplex 4051

Fotos em anexo

continua...
« Última modificação: 21 de Agosto de 2012, 19:58 por Donvan »

Donvan

  • Visitante
O codigo que se segue é o que estou a usar neste momento, ainda está em testes.
o codigo no esta comentado e se tem algum comentarios podem não estar bem, porque vou fazendo o codigo e as veses copio uma coisa ou outra...as veses escrevo em portugues, outras em espanhol e tambem ingles.

Código: [Seleccione]
      int r0 = 0;      //value of select pin at the 4051 (s0)
   int r1 = 0;      //value of select pin at the 4051 (s1)
   int r2 = 0;      //value of select pin at the 4051 (s2)
   
   int red=1, green=50, blue=200, red2=0, green2=49, blue2=199;

   int c = 0;

   int uno[] = {1,2};
   int dos[] = {0,1,3,4,6};
   int tres[] = {0,1,2,3,6};
   int cuatro[] = {1,2,5,6};
   int cinco[] = {0,2,3,5,6};
   int seis[] = {0,2,3,4,5,6};
   int sete[] = {0,1,2};
   int ocho[] = {0,1,2,3,4,5,6};
   int nueve[] = {0,1,2,3,5,6};
   int cero[] = {0,1,2,3,4,5};
   int grau0[] = {0,1,5,6};
   int c10[] = {0,5,6};
   int c20[] = {3,4,6};
 
   int segd= 0;
   int min = 0;
   int mind = 0;
   int hor = 0;
   int hord = 0;
  /* int dir=0, esq=0, reloj=0;
   long t1=0, t2=4294967295;
*/
   int dato = 0;

   int s0=4;
   int s1=7;
   int s2=13;

   int din0=0,din1=0,din2=0,din3=0,din4=0,din5=0,din6=0,din7=0,dinA4;
   float temp1 = 0,temp2=0;
   
   int tu1 = (int) 0.0;
   int  td1=0;  //decimo de temperatura 1
   float tuf1=0;  // float unidade de temperatura 1
     
   int  td2=0;  //decimo de temperatura 2
   float tuf2=0;  // float unidade de temperatura 2
   int tu2 = (int) 0.0;

   int S1=0, S2=0, S3=0, S4=0, rm1=0;
   
   unsigned long time1=4294967295;
   unsigned long time2=4294967295;
   unsigned long time3=4294967295;
   unsigned long time4=4294967295;
   unsigned long time5=4294967295;
   unsigned long time6=4294967295;

   int o0=0,o1=0,o2=0,o3=0,o4=0,o5=0,o6=0,o7=0,o8=0,o9=0,o10=0,o11=0,o12=0,o13=0,
       o14=0,o15=0,o16=0,o17=0,o18=0,o19=0,o20=0,o21=0,o22=0,o23=0,o97=0,o98=0,o99=0;

   char buffer[3];
   int received;

   int ledcam=0;
   int som=0;
   
   #define SHIFTPWM_NOSPI

   // You can choose all pins yourself, but this version is slower than the SPI version
   const int ShiftPWM_dataPin =11;
   const int ShiftPWM_clockPin=12;
   const int ShiftPWM_latchPin=8;

   // If your LED's turn on if the pin is low, set this to 1, otherwise set it to 0.
   const bool ShiftPWM_invertOutputs = 0;

   #include <ShiftPWM.h>   // include ShiftPWM.h after setting the pins!

   // Here you set the number of brightness levels, the update frequency and the number of shift registers.
   // These values affect the load of ShiftPWM.
   // Choose them wisely and use the PrintInterruptLoad() function to verify your load.
   unsigned char maxBrightness = 254;
   unsigned char pwmFrequency = 75;
   int numRegisters = 3;
   int numRGBleds = numRegisters*8/3;

   #include <IRremote.h>
   int RECV_PIN = A5;
   int RECV_PIN2 = 2;
   IRrecv irrecv(RECV_PIN);
   IRrecv irrecv2(RECV_PIN2);
   decode_results results;
   
        void cero1(){
for (c=0; c<=5; c++) {
        r0 = bitRead(cero[c],0);
        r1 = bitRead(cero[c],1);
        r2 = bitRead(cero[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(3, HIGH);
        delayMicroseconds(30);
        digitalWrite(3, LOW);}}

        void uno1(){
for (c=0; c<=1; c++) {
        r0 = bitRead(uno[c],0);
        r1 = bitRead(uno[c],1);
        r2 = bitRead(uno[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
digitalWrite(13, r2);
digitalWrite(3, HIGH);
        delayMicroseconds(30);
        digitalWrite(3, LOW);}}

        void dos1(){
for (c=0; c<=4; c++) {
        r0 = bitRead(dos[c],0);
        r1 = bitRead(dos[c],1);
        r2 = bitRead(dos[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(3, HIGH);
        delayMicroseconds(30);
        digitalWrite(3, LOW);}}

void tres1(){
for (c=0; c<=4; c++) {
        r0 = bitRead(tres[c],0);
        r1 = bitRead(tres[c],1);
        r2 = bitRead(tres[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(3, HIGH);
        delayMicroseconds(30);
        digitalWrite(3, LOW);}}

void cuatro1(){
for (c=0; c<=3; c++) {
        r0 = bitRead(cuatro[c],0);
        r1 = bitRead(cuatro[c],1);
        r2 = bitRead(cuatro[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(3, HIGH);
        delayMicroseconds(30);
        digitalWrite(3, LOW);}}

void cinco1(){
for (c=0; c<=4; c++) {
        r0 = bitRead(cinco[c],0);
        r1 = bitRead(cinco[c],1);
        r2 = bitRead(cinco[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(3, HIGH);
        delayMicroseconds(30);
        digitalWrite(3, LOW);}}

void seis1(){
for (c=0; c<=5; c++) {
        r0 = bitRead(seis[c],0);
        r1 = bitRead(seis[c],1);
        r2 = bitRead(seis[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(3, HIGH);
        delayMicroseconds(30);
        digitalWrite(3, LOW);}}

void sete1(){
for (c=0; c<=2; c++) {
        r0 = bitRead(sete[c],0);
        r1 = bitRead(sete[c],1);
        r2 = bitRead(sete[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(3, HIGH);
        delayMicroseconds(30);
        digitalWrite(3, LOW);}}

void ocho1(){
for (c=0; c<=6; c++) {
        r0 = bitRead(ocho[c],0);
        r1 = bitRead(ocho[c],1);
        r2 = bitRead(ocho[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(3, HIGH);
        delayMicroseconds(30);
        digitalWrite(3, LOW);}}

void nueve1(){
for (c=0; c<=5; c++) {
        r0 = bitRead(nueve[c],0);
        r1 = bitRead(nueve[c],1);
        r2 = bitRead(nueve[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(3, HIGH);
        delayMicroseconds(30);
        digitalWrite(3, LOW);}}

void cero2(){
for (c=0; c<=5; c++) {
        r0 = bitRead(cero[c],0);
        r1 = bitRead(cero[c],1);
        r2 = bitRead(cero[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(5, HIGH);
        delayMicroseconds(30);
        digitalWrite(5, LOW);}}

        void uno2(){
for (c=0; c<=1; c++) {
        r0 = bitRead(uno[c],0);
        r1 = bitRead(uno[c],1);
        r2 = bitRead(uno[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
digitalWrite(13, r2);
digitalWrite(5, HIGH);
        delayMicroseconds(30);
        digitalWrite(5, LOW);}}

        void dos2(){
for (c=0; c<=4; c++) {
        r0 = bitRead(dos[c],0);
        r1 = bitRead(dos[c],1);
        r2 = bitRead(dos[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
    digitalWrite(5, HIGH);
        delayMicroseconds(30);
        digitalWrite(5, LOW);}}

void tres2(){
for (c=0; c<=4; c++) {
        r0 = bitRead(tres[c],0);
        r1 = bitRead(tres[c],1);
        r2 = bitRead(tres[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(5, HIGH);
        delayMicroseconds(30);
        digitalWrite(5, LOW);}}

void cuatro2(){
for (c=0; c<=3; c++) {
        r0 = bitRead(cuatro[c],0);
        r1 = bitRead(cuatro[c],1);
        r2 = bitRead(cuatro[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(5, HIGH);
        delayMicroseconds(30);
        digitalWrite(5, LOW);}}

void cinco2(){
for (c=0; c<=4; c++) {
        r0 = bitRead(cinco[c],0);
        r1 = bitRead(cinco[c],1);
        r2 = bitRead(cinco[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(5, HIGH);
        delayMicroseconds(30);
        digitalWrite(5, LOW);}}

void seis2(){
for (c=0; c<=5; c++) {
        r0 = bitRead(seis[c],0);
        r1 = bitRead(seis[c],1);
        r2 = bitRead(seis[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(5, HIGH);
        delayMicroseconds(30);
        digitalWrite(5, LOW);}}

void sete2(){
for (c=0; c<=2; c++) {
        r0 = bitRead(sete[c],0);
        r1 = bitRead(sete[c],1);
        r2 = bitRead(sete[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(5, HIGH);
        delayMicroseconds(30);
        digitalWrite(5, LOW);}}

void ocho2(){
for (c=0; c<=6; c++) {
        r0 = bitRead(ocho[c],0);
        r1 = bitRead(ocho[c],1);
        r2 = bitRead(ocho[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(5, HIGH);
        delayMicroseconds(30);
        digitalWrite(5, LOW);}}

void nueve2(){
for (c=0; c<=5; c++) {
        r0 = bitRead(nueve[c],0);
        r1 = bitRead(nueve[c],1);
        r2 = bitRead(nueve[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(5, HIGH);
        delayMicroseconds(30);
        digitalWrite(5, LOW);}}

void cero3(){
for (c=0; c<=5; c++) {
        r0 = bitRead(cero[c],0);
        r1 = bitRead(cero[c],1);
        r2 = bitRead(cero[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(6, HIGH);
        delayMicroseconds(30);
        digitalWrite(6, LOW);}}

        void uno3(){
for (c=0; c<=1; c++) {
        r0 = bitRead(uno[c],0);
        r1 = bitRead(uno[c],1);
        r2 = bitRead(uno[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
digitalWrite(13, r2);
digitalWrite(6, HIGH);
        delayMicroseconds(30);
        digitalWrite(6, LOW);}}

        void dos3(){
for (c=0; c<=4; c++) {
        r0 = bitRead(dos[c],0);
        r1 = bitRead(dos[c],1);
        r2 = bitRead(dos[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(6, HIGH);
        delayMicroseconds(30);
        digitalWrite(6, LOW);}}

void tres3(){
for (c=0; c<=4; c++) {
        r0 = bitRead(tres[c],0);
        r1 = bitRead(tres[c],1);
        r2 = bitRead(tres[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(6, HIGH);
        delayMicroseconds(30);
        digitalWrite(6, LOW);}}

void cuatro3(){
for (c=0; c<=3; c++) {
        r0 = bitRead(cuatro[c],0);
        r1 = bitRead(cuatro[c],1);
        r2 = bitRead(cuatro[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(6, HIGH);
        delayMicroseconds(30);
        digitalWrite(6, LOW);}}

void cinco3(){
for (c=0; c<=4; c++) {
        r0 = bitRead(cinco[c],0);
        r1 = bitRead(cinco[c],1);
        r2 = bitRead(cinco[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(6, HIGH);
        delayMicroseconds(30);
        digitalWrite(6, LOW);}}

void seis3(){
for (c=0; c<=5; c++) {
        r0 = bitRead(seis[c],0);
        r1 = bitRead(seis[c],1);
        r2 = bitRead(seis[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(6, HIGH);
        delayMicroseconds(30);
        digitalWrite(6, LOW);}}

void sete3(){
        for (c=0; c<=2; c++) {
        r0 = bitRead(sete[c],0);
        r1 = bitRead(sete[c],1);
        r2 = bitRead(sete[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(6, HIGH);
        delayMicroseconds(30);
        digitalWrite(6, LOW);}}

void ocho3(){
        for (c=0; c<=6; c++) {
        r0 = bitRead(ocho[c],0);
        r1 = bitRead(ocho[c],1);
        r2 = bitRead(ocho[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(6, HIGH);
        delayMicroseconds(30);
        digitalWrite(6, LOW);}}

void nueve3(){
        for (c=0; c<=5; c++) {
        r0 = bitRead(nueve[c],0);
        r1 = bitRead(nueve[c],1);
        r2 = bitRead(nueve[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(6, HIGH);
        delayMicroseconds(30);
        digitalWrite(6, LOW);}}

        void cero4(){
for (c=0; c<=5; c++) {
        r0 = bitRead(cero[c],0);
        r1 = bitRead(cero[c],1);
        r2 = bitRead(cero[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

        void uno4(){
        for (c=0; c<=1; c++) {
        r0 = bitRead(uno[c],0);
        r1 = bitRead(uno[c],1);
        r2 = bitRead(uno[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

        void dos4(){
for (c=0; c<=4; c++) {
        r0 = bitRead(dos[c],0);
        r1 = bitRead(dos[c],1);
        r2 = bitRead(dos[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

void tres4(){
for (c=0; c<=4; c++) {
        r0 = bitRead(tres[c],0);
        r1 = bitRead(tres[c],1);
        r2 = bitRead(tres[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

void cuatro4(){
for (c=0; c<=3; c++) {
        r0 = bitRead(cuatro[c],0);
        r1 = bitRead(cuatro[c],1);
        r2 = bitRead(cuatro[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

void cinco4(){
for (c=0; c<=4; c++) {
        r0 = bitRead(cinco[c],0);
        r1 = bitRead(cinco[c],1);
        r2 = bitRead(cinco[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

void seis4(){
for (c=0; c<=5; c++) {
        r0 = bitRead(seis[c],0);
        r1 = bitRead(seis[c],1);
        r2 = bitRead(seis[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

void sete4(){
for (c=0; c<=2; c++) {
        r0 = bitRead(sete[c],0);
        r1 = bitRead(sete[c],1);
        r2 = bitRead(sete[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

void ocho4(){
for (c=0; c<=6; c++) {
        r0 = bitRead(ocho[c],0);
        r1 = bitRead(ocho[c],1);
        r2 = bitRead(ocho[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

void nueve4(){
for (c=0; c<=5; c++) {
        r0 = bitRead(nueve[c],0);
        r1 = bitRead(nueve[c],1);
        r2 = bitRead(nueve[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

void grau(){
    for (c=0; c<=3; c++) {
        r0 = bitRead(grau0[c],0);
        r1 = bitRead(grau0[c],1);
        r2 = bitRead(grau0[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
digitalWrite(13, r2);
digitalWrite(6, HIGH);
        delayMicroseconds(30);
        digitalWrite(6, LOW);}}

void c1(){
for (c=0; c<=2; c++) {
        r0 = bitRead(c10[c],0);
        r1 = bitRead(c10[c],1);
        r2 = bitRead(c10[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

void c2(){
for (c=0; c<=2; c++) {
        r0 = bitRead(c20[c],0);
        r1 = bitRead(c20[c],1);
        r2 = bitRead(c20[c],2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
digitalWrite(13, r2);
digitalWrite(9, HIGH);
        delayMicroseconds(30);
        digitalWrite(9, LOW);}}

    void setup(){
   
      Serial.begin(9600);
      pinMode(4, OUTPUT);    // s0
      pinMode(7, OUTPUT);    // s1
      pinMode(13, OUTPUT);   // s2
      pinMode(3, OUTPUT);    // LedDisplay 1
      pinMode(5, OUTPUT);    // LedDisplay 2
      pinMode(6, OUTPUT);    // LedDisplay 3
      pinMode(9, OUTPUT);    // LedDisplay 4
      pinMode(ShiftPWM_latchPin, OUTPUT);
      pinMode(ShiftPWM_clockPin, OUTPUT);
      pinMode(ShiftPWM_dataPin,  OUTPUT);

      // Sets the number of 8-bit registers that are used.
      ShiftPWM.SetAmountOfRegisters(numRegisters);

      // SetPinGrouping allows flexibility in LED setup.
      // If your LED's are connected like this: RRRRGGGGBBBBRRRRGGGGBBBB, use SetPinGrouping(4).
      ShiftPWM.SetPinGrouping(1); //This is the default, but I added here to demonstrate how to use the funtion
 
      ShiftPWM.Start(pwmFrequency,maxBrightness);
 
      received = 0;
     
      irrecv.enableIRIn();
      irrecv2.enableIRIn();
      }
   continua o codigo

continua...
« Última modificação: 21 de Agosto de 2012, 20:15 por Donvan »

Donvan

  • Visitante
 
Código: [Seleccione]
static unsigned long ult_tempo = 0;
int tempo = millis();
if(tempo - ult_tempo >= 1000) {
ult_tempo = tempo;
S1++;S2++;S3++;S4++;}
if (s1>=1000){S1=0;} if (S2>=1000){S2=0;} if (S3>=1000){S3=0;} if (S4>=1000){S4=0;}
if (irrecv.decode(&results)) {
if (o0==0 && results.value == 756507362){o0=1;ShiftPWM.SetOne(0, 255);ShiftPWM.SetOne(8, 255);som=1;results.value=0;delay(200);}
if (o0==1 && results.value == 756507362){o0=0;ShiftPWM.SetOne(0, 0);ShiftPWM.SetOne(8, 0);som=0;results.value=0;delay(200);}
if (o3==0 && results.value == 718965557){o3=1;ShiftPWM.SetOne(3, 255);results.value=0;delay(200);}
if (o3==1 && results.value == 718965557){o3=0;ShiftPWM.SetOne(3, 0);results.value=0;delay(200);}
//if (o98==0 && results.value == 1966200847){o98=1;o3=1;results.value=0;delay(200);time5=millis()+15000;}
//if (o98==1 && results.value == 1966200847){o98=0;o3=0;results.value=0;delay(200);}
if (o16==0 && results.value == 3477319588){o16=1;ShiftPWM.SetOne(16, 255);results.value=0;delay(200);time4=millis()+3500;}
if (o16==1 && results.value == 3477319588){o16=0;ShiftPWM.SetOne(16, 0);results.value=0;delay(200);}
if (o16==0 && results.value == 1125512974){o99=1;ShiftPWM.SetOne(16, 255);results.value=0;delay(200);time6=millis()+300;}
if (o11==0 && results.value == 2902783540){o11=1;ShiftPWM.SetOne(11, 255);results.value=0;delay(200);}
if (o11==1 && results.value == 2902783540){o11=0;ShiftPWM.SetOne(11, 0);results.value=0;delay(200);}
if (o12==0 && results.value == 3523702540){o12=1;ShiftPWM.SetOne(12, 255);results.value=0;delay(200);}
if (o12==1 && results.value == 3523702540){o12=0;ShiftPWM.SetOne(12, 0);results.value=0;delay(200);}
if (o13==0 && results.value == 3812570202){o13=1;ShiftPWM.SetOne(13, 255);results.value=0;delay(200);}
if (o13==1 && results.value == 3812570202){o13=0;ShiftPWM.SetOne(13, 0);results.value=0;delay(200);}
if (o14==0 && results.value == 1881032211){o14=1;ShiftPWM.SetOne(14, 255);results.value=0;delay(200);}
if (o14==1 && results.value == 1881032211){o14=0;ShiftPWM.SetOne(14, 0);results.value=0;delay(200);}
if (o10==0 && results.value == 1691675886){o10=1;ShiftPWM.SetOne(10, 255);ledcam=1;results.value=0;delay(200);}
if (o10==1 && results.value == 1691675886){o10=0;ShiftPWM.SetOne(10, 0);ledcam=0;results.value=0;delay(200);}
irrecv.resume(); 
}
if (irrecv2.decode(&results)) {
if (o0==0 && (results.value == 16744575 || results.value == 756507362)){o0=1;ShiftPWM.SetOne(0, 255);ShiftPWM.SetOne(8, 255);som=1;results.value=0;delay(200);}
if (o0==1 && (results.value == 16744575 || results.value == 756507362)){o0=0;ShiftPWM.SetOne(0, 0);ShiftPWM.SetOne(8, 0);som=0;results.value=0;delay(200);}
if (o3==0 && (results.value == 16728255 || results.value == 718965557)){o3=1;ShiftPWM.SetOne(3, 255);results.value=0;delay(200);}
if (o3==1 && (results.value == 16728255 || results.value == 718965557)){o3=0;ShiftPWM.SetOne(3, 0);results.value=0;delay(200);}
//if (o98==0 && (results.value == 16711935 || results.value == 1966200847)){o98=1;o3=1;results.value=0;delay(200);time5=millis()+15000;}
//if (o98==1 && (results.value == 16711935 || results.value == 1966200847)){o98=0;o3=0;results.value=0;delay(200);}
if (o16==0 && (results.value == 16732335 || results.value == 3477319588)){o16=1;ShiftPWM.SetOne(16, 255);results.value=0;delay(200);time4=millis()+3500;}
if (o16==1 && (results.value == 16732335 || results.value == 3477319588)){o16=0;ShiftPWM.SetOne(16, 0);results.value=0;delay(200);}
if (o16==0 && (results.value == 16760895 || results.value == 1125512974)){o99=1;ShiftPWM.SetOne(16, 255);results.value=0;delay(200);time6=millis()+300;}
if (o11==0 && (results.value == 16720095 || results.value == 2902783540)){o11=1;ShiftPWM.SetOne(11, 255);results.value=0;delay(200);}
if (o11==1 && (results.value == 16720095 || results.value == 2902783540)){o11=0;ShiftPWM.SetOne(11, 0);results.value=0;delay(200);}
if (o12==0 && (results.value == 16752735 || results.value == 3523702540)){o12=1;ShiftPWM.SetOne(12, 255);results.value=0;delay(200);}
if (o12==1 && (results.value == 16752735 || results.value == 3523702540)){o12=0;ShiftPWM.SetOne(12, 0);results.value=0;delay(200);}
if (o13==0 && (results.value == 16769055 || results.value == 3812570202)){o13=1;ShiftPWM.SetOne(13, 255);results.value=0;delay(200);}
if (o13==1 && (results.value == 16769055 || results.value == 3812570202)){o13=0;ShiftPWM.SetOne(13, 0);results.value=0;delay(200);}
if (o14==0 && (results.value == 16736415 || results.value == 1881032211)){o14=1;ShiftPWM.SetOne(14, 255);results.value=0;delay(200);}
if (o14==1 && (results.value == 16736415 || results.value == 1881032211)){o14=0;ShiftPWM.SetOne(14, 0);results.value=0;delay(200);}
if (o10==0 && (results.value == 16742535 || results.value == 1691675886)){o10=1;ShiftPWM.SetOne(10, 255);ledcam=1;results.value=0;delay(200);}
if (o10==1 && (results.value == 16742535 || results.value == 1691675886)){o10=0;ShiftPWM.SetOne(10, 0);ledcam=0;results.value=0;delay(200);}
if (o97==0 && (results.value == 16740495 || results.value == 1061916520)){o97=1;results.value=0;delay(200);}
if (o97==1 && (results.value == 16740495 || results.value == 1061916520)){o97=0;results.value=0;delay(200);}
irrecv2.resume(); 
}
if(Serial.available()){
char c = Serial.read();
if(c == 97){
int dato = atoi(buffer);
received = 0;
/*   
if (o0==0 && dato==0){o1=1;o9=1;Serial.print("o1:");Serial.println(o1);dato=0;}
if (o0==1 && dato==0){o1=0;o9=0;Serial.print("o1:");Serial.println(o1);dato=0;}
if (o1==0 && dato==1){o2=2;Serial.print("o2:");Serial.println(o2);dato=0;}
if (o1==1 && dato==1){o2=0;Serial.print("o2:");Serial.println(o2);dato=0;}
if (o2==0 && dato==2){o3=4;Serial.print("o3:");Serial.println(o3);dato=0;}
if (o2==1 && dato==2){o3=0;Serial.print("o3:");Serial.println(o3);dato=0;}
if (o3==0 && dato==3){o3=1;ShiftPWM.SetOne(3, 255);Serial.print("o3:");Serial.println(o3);dato=0;}
if (o3==1 && dato==3){o3=0;ShiftPWM.SetOne(3, 0);Serial.print("o3:");Serial.println(o3);dato=0;}
if (o4==0 && dato==4){o5=16;Serial.print("o5:");Serial.println(o5);dato=0;}
if (o4==1 && dato==4){o5=0;Serial.print("o5:");Serial.println(o5);dato=0;}
if (o5==0 && dato==5){o6=32;Serial.print("o6:");Serial.println(o6);dato=0;}
if (o5==1 && dato==5){o6=0;Serial.print("o6:");Serial.println(o6);dato=0;}
if (o6==0 && dato==6){o7=64;Serial.print("o7:");Serial.println(o7);dato=0;}
if (o6==1 && dato==6){o7=0;Serial.print("o7:");Serial.println(o7);dato=0;}
if (o7==0 && dato==7){o8=128;Serial.print("o8:");Serial.println(o8);dato=0;}
if (o7==1 && dato==7){o8=0;Serial.print("o8:");Serial.println(o8);dato=0;}
if (o8==0 && dato==8){o9=1;Serial.print("o9:");Serial.println(o9);dato=0;}
if (o8==1 && dato==8){o9=0;Serial.print("o9:");Serial.println(o9);dato=0;}
if (o9==0 && dato==9){o10=2;Serial.print("o10:");Serial.println(o10);dato=0;}
if (o9==1 && dato==9){o10=0;Serial.print("o10:");Serial.println(o10);dato=0;}
if (o10==0 && dato==10){o11=4;Serial.print("o11:");Serial.println(o11);dato=0;}
if (o10==1 && dato==10){o11=0;Serial.print("o11:");Serial.println(o11);dato=0;}
if (o11==0 && dato==11){o12=8;Serial.print("o12:");Serial.println(o12);dato=0;}
if (o11==1 && dato==11){o12=0;Serial.print("o12:");Serial.println(o12);dato=0;}
if (o12==0 && dato==12){o13=16;Serial.print("o13:");Serial.println(o13);dato=0;}
if (o12==1 && dato==12){o13=0;Serial.print("o13:");Serial.println(o13);dato=0;}
if (o13==0 && dato==13){o14=32;Serial.print("o14:");Serial.println(o14);dato=0;}
if (o13==1 && dato==13){o14=0;Serial.print("o14:");Serial.println(o14);dato=0;}
if (o14==0 && dato==14){o15=64;Serial.print("o15:");Serial.println(o15);dato=0;}
if (o14==1 && dato==14){o15=0;Serial.print("o15:");Serial.println(o15);dato=0;}
if (o15==0 && dato==15){o16=128;Serial.print("o16:");Serial.println(o16);dato=0;}
if (o15==1 && dato==15){o16=0;Serial.print("o16:");Serial.println(o16);dato=0;}
if (o16==0 && dato==16){o17=1;Serial.print("o17:");Serial.println(o17);dato=0;}
if (o16==1 && dato==16){o17=0;Serial.print("o17:");Serial.println(o17);dato=0;}
if (o17==0 && dato==17){o18=2;ShiftPWM.SetOne(17, 255);Serial.print("o18:");Serial.println(o18);dato=0;}
if (o17==1 && dato==17){o18=0;ShiftPWM.SetOne(17, 0);Serial.print("o18:");Serial.println(o18);dato=0;}
if (o18==0 && dato==18){o19=4;Serial.print("o19:");Serial.println(o19);dato=0;}
if (o18==1 && dato==18){o19=0;Serial.print("o19:");Serial.println(o19);dato=0;}
if (o19==0 && dato==19){o20=8;Serial.print("o20:");Serial.println(o20);dato=0;}
if (o19==1 && dato==19){o20=0;Serial.print("o20:");Serial.println(o20);dato=0;}
if (o20==0 && dato==20){o21=16;Serial.print("o21:");Serial.println(o21);dato=0;}
if (o20==1 && dato==20){o21=0;Serial.print("o21:");Serial.println(o21);dato=0;}
if (o21==0 && dato==21){o22=32;Serial.print("o22:");Serial.println(o22);dato=0;}
if (o21==1 && dato==21){o22=0;Serial.print("o22:");Serial.println(o22);dato=0;}
if (o22==0 && dato==22){o23=64;Serial.print("o23:");Serial.println(o23);dato=0;}
if (o22==1 && dato==22){o23=0;Serial.print("o23:");Serial.println(o23);dato=0;}
if (o23==0 && dato==23){o23=128;Serial.print("o23:");Serial.println(o23);dato=0;}
if (o23==1 && dato==23){o23=0;Serial.print("o23:");Serial.println(o23);dato=0;}
if (o97==0 && dato==97){o97=1;Serial.print("RGB ON:");Serial.println(o97);dato=0;}
if (o97==1 && dato==97){o97=0;Serial.print("RGB Off:");Serial.println(o97);dato=0;}
/*if (o98==0 && dato==98){o98=1;o9=1;results.value=0;delay(200);time5=millis()+15000;Serial.print("o98:");Serial.println(o98);dato=0;}
if (o98==1 && dato==98){o98=0;o9=0;Serial.print("o98:");Serial.println(o98);dato=0;}
*/ 
if (dato==25){dato=0;hor++;}
if (dato==26){dato=0;mind++;}
if (dato==27){dato=0;min++;}
if (dato==28){dato=0;segd++;}
}
     
if(c != 97){
buffer[received++] = c;
}
Serial.flush();
}
   
if (o99==1 && time6<=millis()){o99=0;ShiftPWM.SetOne(16, 0);;time6=4294967295;}  //Fim de pulso rele
if (o16==1 && time4<=millis()){o16=0;ShiftPWM.SetOne(16, 0);time4=4294967295;}

/*if (o98==1 && time5<=millis()){o3=0;time1=millis()+15000;time5=4294967295;}   //ex. de simulador de presença
if (o98==1 && time1<=millis()){o3=1;time2=millis()+5000;time1=4294967295;}
if (o98==1 && time2<=millis()){o3=0;time3=millis()+5000;time2=4294967295;}
if (o98==1 && time3<=millis()){o3=1;time5=millis()+10000;time3=4294967295;}
*/
if(o97==1){
if (red>red2){red++;;red2++;ShiftPWM.SetOne(18, red);ShiftPWM.SetOne(21,red2);}
if (red>252){red=252;red2=253;}
if (red<red2){red--;red2--;ShiftPWM.SetOne(18, red);ShiftPWM.SetOne(21, red2);}
if (red<1){red=1;red2=0;}
 
if (green>green2){green++;;green2++;ShiftPWM.SetOne(19, green);ShiftPWM.SetOne(22, green2);}
if (green>251){green=251;green2=252;}
if (green<green2){green--;green2--;ShiftPWM.SetOne(19, green);ShiftPWM.SetOne(22, green2);}
if (green<1){green=1;green2=0;}

if (blue>blue2){blue++;;blue2++;ShiftPWM.SetOne(20, blue);ShiftPWM.SetOne(23, blue2);}
if (blue>250){blue=250;blue2=251;}
if (blue<blue2){blue--;blue2--;ShiftPWM.SetOne(20, blue);ShiftPWM.SetOne(23, blue2);}
if (blue<1){blue=1;blue2=0;}}
else{ShiftPWM.SetOne(18, 0);ShiftPWM.SetOne(19, 0);ShiftPWM.SetOne(20, 0);
ShiftPWM.SetOne(21, 0);ShiftPWM.SetOne(22, 0);ShiftPWM.SetOne(23, 0);}
if(S1>=10) {
S1 = 0;
segd++;
}
if(segd>=6) {
segd = 0;
min++;}
if(min>=10) {
min = 0;
mind++;}
if(mind>=6) {
mind = 0;
hor++;}
if(hor>=10) {
hor = 0;
hord++;}
if(hord>=2 && hor>=4) {
hor = 0;
hord = 0;}
if(S3>=2){S3=0;}
if(S4>=30){S4=0;}

if(/*reloj==0 && */S4>=0 && S4 <=1){
grau();
c1();
switch (tu1) {
case 0:
cero2();
break;
case 1:
uno2();
break;
case 2:
dos2();
break;
case 3:
tres2();
break;
case 4:
cuatro2();
break;
case 5:
cinco2();
break;
case 6:
seis2();
break;
case 7:
sete2();
break;
case 8:
ocho2();
break;
case 9:
nueve2();
}
switch (td1) {
case 0:
cero1();
break;
case 1:
uno1();
break;
case 2:
dos1();
break;
case 3:
tres1();
break;
case 4:
cuatro1();
break;
case 5:
cinco1();
break;
case 6:
seis1();
break;
case 7:
sete1();
break;
case 8:
ocho1();
break;
case 9:
nueve1();
}
}

if(/*reloj==0 && */S4>=2 && S4 <=3){
grau();
c2();
switch (tu2) {
case 0:
cero2();
break;
case 1:
uno2();
break;
case 2:
dos2();
break;
case 3:
tres2();
break;
case 4:
cuatro2();
break;
case 5:
cinco2();
break;
case 6:
seis2();
break;
case 7:
sete2();
break;
case 8:
ocho2();
break;
case 9:
nueve2();
}
switch (td2) {
case 0:
cero1();
break;
case 1:
uno1();
break;
case 2:
dos1();
break;
case 3:
tres1();
break;
case 4:
cuatro1();
break;
case 5:
cinco1();
break;
case 6:
seis1();
break;
case 7:
sete1();
break;
case 8:
ocho1();
break;
case 9:
nueve1();
}
}

  if (S4>=4 && S4<=29){
  switch (S3) {
        case 0:
        r0 = bitRead(7,0);
        r1 = bitRead(7,1);
        r2 = bitRead(7,2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
        digitalWrite(5, HIGH);
        delayMicroseconds(30);
        digitalWrite(5, LOW);
      break;
      case 1:
        r0 = bitRead(7,0);
        r1 = bitRead(7,1);
        r2 = bitRead(7,2);
        digitalWrite(4, r0);
        digitalWrite(7, r1);
        digitalWrite(13, r2);
        digitalWrite(5, LOW);
        delayMicroseconds(30);
        digitalWrite(5, LOW);
     
}
     switch (min) {
        case 0:
        cero4();
      break;
      case 1:
        uno4();
      break;
      case 2:
dos4();
      break;
      case 3:
        tres4();
      break;
      case 4:
        cuatro4();
      break;
      case 5:
        cinco4();
      break;
      case 6:
        seis4();
      break;
      case 7:
        sete4();
       break;
      case 8:
        ocho4();
      break;
      case 9:
        nueve4();
      }
      switch (mind) {
        case 0:
        cero3();
      break;
      case 1:
        uno3();
      break;
      case 2:
dos3();
      break;
      case 3:
        tres3();
      break;
      case 4:
        cuatro3();
      break;
      case 5:
        cinco3();
      break;
      case 6:
        seis3();
      break;
      case 7:
        sete3();
       break;
      case 8:
        ocho3();
      break;
      case 9:
        nueve3();
  }
      switch (hor) {
        case 0:
        cero2();
      break;
      case 1:
        uno2();
      break;
      case 2:
dos2();
      break;
      case 3:
        tres2();
      break;
      case 4:
        cuatro2();
      break;
      case 5:
        cinco2();
      break;
      case 6:
        seis2();
      break;
      case 7:
        sete2();
       break;
      case 8:
        ocho2();
      break;
      case 9:
        nueve2();
      }
      switch (hord) {
      case 1:
        uno1();
      break;
      case 2:
dos1();
      }
}
     
  /*digitalWrite(s0, LOW);
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  din0=analogRead(A0);
  delayMicroseconds(30);
  */
  digitalWrite(s0, HIGH);
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  din1=analogRead(A0);
  temp2=(23+((530-din1)/9.8));
  delayMicroseconds(30);
 
  digitalWrite(s0, LOW);
  digitalWrite(s1, HIGH);
  digitalWrite(s2, LOW);
  din2=analogRead(A0);
  temp1=(23+((530-din2)/9.8));
  delayMicroseconds(30);
 
  digitalWrite(s0, HIGH);
  digitalWrite(s1, HIGH);
  digitalWrite(s2, LOW);
  din3=analogRead(A0);
  delayMicroseconds(30);
 
  digitalWrite(s0, LOW);
  digitalWrite(s1, LOW);
  digitalWrite(s2, HIGH);
  din4=analogRead(A0);
  delayMicroseconds(30);
 
/*digitalWrite(s0, HIGH);
  digitalWrite(s1, LOW);
  digitalWrite(s2, HIGH);
  din5=analogRead(A0);
  delayMicroseconds(30);
 
  digitalWrite(s0, LOW);
  digitalWrite(s1, HIGH);
  digitalWrite(s2, HIGH);
  din6=analogRead(A0);
  delayMicroseconds(30);
 
  digitalWrite(s0, HIGH);
  digitalWrite(s1, HIGH);
  digitalWrite(s2, HIGH);
  din7=analogRead(A0);
  delayMicroseconds(30);
 */
  td1=(temp1/10);
  tuf1=((temp1/10.0)-td1)*10.0+0.5;
  tu1=tuf1;
 
  td2=(temp2/10);
  tuf2=((temp2/10.0)-td2)*10.0+0.5;
  tu2=tuf2;
 
  /*
  if (S2==5){S2=0;
  Serial.print("  P0: ");
  Serial.print(din0);
  Serial.print("  Temp2: ");
  Serial.print(temp2);
  Serial.print("  Temp1: ");
  Serial.print(temp1);
  Serial.print("  LDR: ");
  Serial.print(din3);
  Serial.print("  P4: ");
  Serial.print(din4);
  Serial.print("  P5: ");
  Serial.print(din5);
  Serial.print("  P6: ");
  Serial.print(din6);
  Serial.print("  P7: ");
  Serial.println(din7);
  dinA4=digitalRead(A4);
  Serial.print("  DetM: ");
  Serial.println(dinA4);
  Serial.print(td1);
  Serial.println(tu1);
  Serial.print(td2);
  Serial.println(tu2);}
  */       
    if (som==0 && temp1<17){
    ShiftPWM.SetOne(4, 0);ShiftPWM.SetOne(6, 255);ShiftPWM.SetOne(7, 0);ShiftPWM.SetOne(9, 0);}   
    else if (som==0 && temp1<27){
    ShiftPWM.SetOne(4, 20);ShiftPWM.SetOne(6, 0);ShiftPWM.SetOne(7, 0);ShiftPWM.SetOne(9, 0);}
    else if (som==0 && temp1<=29){
    ShiftPWM.SetOne(4, 0);ShiftPWM.SetOne(6, 0);ShiftPWM.SetOne(7, 255);ShiftPWM.SetOne(9, 180);S4=0;}
    else if (som==0 && temp1>29){
    ShiftPWM.SetOne(4, 0);ShiftPWM.SetOne(6, 0);ShiftPWM.SetOne(7, 255);ShiftPWM.SetOne(9, 255);S4=0;}
   
    /*if(din5==677 && t1==0){t1=millis()+3000;}
    if (t1<=millis() && din5==677){reloj=1;S4=4;t2=millis()+5000;delay(500);}
    if (dir==1){if(din7==677){min++;delay(100);t2=millis()+5000;S4=4;}if(din7==1023){min--;if(min<0){min=9;mind--;if(mind<0){mind=5;}}delay(100);t2=millis()+5000;S4=4;}}
    if (esq==1){if(din7==677){hor++;delay(100);t2=millis()+5000;S4=4;}if(din7==1023){hor--;if(hor<0){hor=9;hord--;if(hord<0){hor=3;hord=2;}}delay(100);t2=millis()+5000;S4=4;}}
    if(din6==677 && reloj==1){dir=1;esq=0;t2=millis()+5000;delay(500);S4=4;}
    if(din6==1023 && reloj==1){esq=1;dir=0;t2=millis()+5000;delay(500);S4=4;}
    if(t2<=millis()){reloj=0;t1=0;dir=0;esq=0;t2=4294967295;}
  */
    if (som==1 && S3==1){ShiftPWM.SetOne(4, 0);}
  else if (som==1 && S3==0){ShiftPWM.SetOne(4, 255);}
     
   if (ledcam==0 && temp2<17){
    ShiftPWM.SetOne(15, 0);ShiftPWM.SetOne(1, 255);ShiftPWM.SetOne(2, 0);}   
    else if (ledcam==0 && temp2<=26){
    ShiftPWM.SetOne(15, 255);ShiftPWM.SetOne(2, 0);}   
    else if (ledcam==0 && temp2>=27){
    ShiftPWM.SetOne(15, 0);ShiftPWM.SetOne(2, 255);}   
 
   if (ledcam==1){ShiftPWM.SetOne(15, 255);ShiftPWM.SetOne(1, 255);ShiftPWM.SetOne(2, 255);}   
   
   if (din4==0){software_Reset();}
   
   if ((o0+o3+o8+o98+o11+o12+o13+o14)>=1){ShiftPWM.SetOne(1, 255);}
   else {ShiftPWM.SetOne(1, 0);} //*por agora
   
 
      }
     
      void software_Reset() // Restarts program from beginning but does not reset the peripherals and registers
  {
  asm volatile ("  jmp 0");

« Última modificação: 21 de Agosto de 2012, 20:12 por Donvan »

Donvan

  • Visitante
Viva!

Actualizei um pouco o codigo, agora tem a biblioteca ShiftPWM...
adicionei 2 led's RGB
coloquei os transistor's que faltava, etc...

tenho de fazer um video para o pessoal ver a funcionar...

Abraço!

Deus Abençõe