Home Forum Scrivi una domanda di elettronica arduino ethernet + osc

Questo argomento contiene 0 risposte, ha 1 partecipante, ed è stato aggiornato da  marco.slongo.9 1 anno, 4 mesi fa.

Stai vedendo 1 articolo (di 1 totali)
  • Autore
    Articoli
  • #59767

    Salve io ho questo sketch

    #include “Ethernet.h”
    #include “OSCClass.h”
    #include “SPI.h”

    int pinLedA=2;
    int pinLedB=3;
    int pinLedC=4;
    int pinLedD=5;
    int pinLedE=6;
    int pinLedF=7;

    OSCMessage recMes;

    OSCClass osc(&recMes);

    byte serverMac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    byte serverIp[] = { 192, 168, 2, 130 };
    int serverPort = 10000;

    char *topAddress=”butt”;
    char *subAddress[15]={ “ledA” , “ledB” , “ledC”, “ledD” , “ledE” , “ledF”, “ledAB” , “ledBC” , “ledAC”, “ledDE” , “ledEF” , “ledDF”, “fadeB” , “fadeD” , “fadeE” };

    void setup() {
    Ethernet.begin(serverMac ,serverIp);
    osc.begin(serverPort);

    pinMode(pinLedA, OUTPUT);
    pinMode(pinLedB, OUTPUT);
    pinMode(pinLedC, OUTPUT);
    pinMode(pinLedD, OUTPUT);
    pinMode(pinLedE, OUTPUT);
    pinMode(pinLedF, OUTPUT);

    digitalWrite(pinLedA, LOW); //LED OFF
    digitalWrite(pinLedB, LOW); //LED OFF
    digitalWrite(pinLedC, LOW); //LED OFF
    digitalWrite(pinLedD, LOW); //LED OFF
    digitalWrite(pinLedE, LOW); //LED OFF
    digitalWrite(pinLedF, LOW); //LED OFF

    osc.flush();
    }

    void loop() {
    if ( osc.available() ) {
    if( !strcmp( recMes.getAddress(0) , topAddress ) ){
    if( !strcmp( recMes.getAddress(1) , subAddress[0] ) ) { digitalWrite(pinLedA, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[1] ) ) { digitalWrite(pinLedB, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[2] ) ) { digitalWrite(pinLedC, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[3] ) ) { digitalWrite(pinLedD, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[4] ) ) { digitalWrite(pinLedE, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[5] ) ) { digitalWrite(pinLedF, getIntValue(&recMes)); }

    if( !strcmp( recMes.getAddress(1) , subAddress[6] ) ) { digitalWrite(pinLedA, getIntValue(&recMes)); digitalWrite(pinLedB, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[7] ) ) { digitalWrite(pinLedB, getIntValue(&recMes)); digitalWrite(pinLedC, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[8] ) ) { digitalWrite(pinLedA, getIntValue(&recMes)); digitalWrite(pinLedC, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[9] ) ) { digitalWrite(pinLedD, getIntValue(&recMes)); digitalWrite(pinLedE, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[10] ) ) { digitalWrite(pinLedE, getIntValue(&recMes)); digitalWrite(pinLedF, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[11] ) ) { digitalWrite(pinLedD, getIntValue(&recMes)); digitalWrite(pinLedF, getIntValue(&recMes)); }

    if( !strcmp( recMes.getAddress(1) , subAddress[12] ) ) { analogWrite(pinLedB, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[13] ) ) { analogWrite(pinLedD, getIntValue(&recMes)); }
    if( !strcmp( recMes.getAddress(1) , subAddress[14] ) ) { analogWrite(pinLedE, getIntValue(&recMes)); }

    }
    }
    }

    // ********* utility ***********************************

    int getIntValue(OSCMessage *mes){
    switch( mes->getTypeTag(0) ){
    case ‘i': { return mes->getArgInt(0); }
    break;

    case ‘f': { return int(mes->getArgFloat(0)); }
    break;
    }
    }
    http://www.mauroalfieri.it/elettronica/arduino-osc-iphone-e-sei-led-lo-sketch.html io vorrei modificarlo, vorrei gestire un altro Led con un pulsante senza l utilizza della rete( quando schiaccio il pulsante si accende e se lo rilascio si spegne) spero che qualcuno sappia aiutarmi, grazie

Stai vedendo 1 articolo (di 1 totali)

Devi aver eseguito l’accesso per poter rispondere a questa discussione.