Gracias Norber!!!!
Ya mismo y luego de finalizar tarea remota (llevamos 18 días de aislamiento y viene para largo) me pondré a hacer el negativo para la fabricación de los impresos.
Gracias Norber. Gracias Foro!
Claudio
Moderador: 241-2001
12 occupancy sensors (activated when the pins are connected to GND):
Pin 7 es LED en placa
Pins 8 to 13 (six first sensors)
Pins A0 to A5 (six last sensors)
*/
#define NUM_S88 0 // Number assigned to the first sensor reported from this feedback module
#define CLOCK 3 // Connect S88 CLOCK signal to Arduino pin3 - don't change this
#define LOAD_PS 4 // Connect S88 LOAD_PS signal to Arduino pin4
#define DATA_IN 5 // Connect S88 DATA from next S88 feedback module to Arduino pin 5
#define DATA_OUT 6 // Output DATA to next S88 feedback module or the PC interface to Arduino pin6
#define LED 7
void setup() {
pinMode(LOAD_PS, INPUT);
pinMode(CLOCK, INPUT);
pinMode(DATA_IN, INPUT);
pinMode(DATA_OUT, OUTPUT);
digitalWrite(DATA_OUT, LOW);
pinMode(LED, OUTPUT);
digitalWrite(LED, HIGH);
for (int i = 8; i < 20; i++) {
pinMode(i, INPUT_PULLUP);
}
delay(2000);
digitalWrite(LED, LOW);
attachInterrupt(1, clockS88, RISING); // pin3 = CLOCK externalInterrupt 1
}
void clockS88() { // Rising edge CLOCK signal interruption
static byte cont;
static int data;
if (PIND & (1 << LOAD_PS)) { // Let's load my sensors info
data = ~(((PINC & 0x3F)<<6) + (PINB & 0x3F)); // Load my sensors in 'data' (6 lowest bits of B and C ports)
data = data & 0x0FFF;
if (data) digitalWrite(LED, HIGH);
else digitalWrite(LED, LOW);
cont = 0; // Start counter of data transmited
}
if (cont == NUM_S88) { // Our turn: let's empty / shift / fill 'data'
if (data & 0x01) PORTD |= (1<< DATA_OUT); // Put in DATA_OUT the state of bit 'data0'
else PORTD &= ~(1 << DATA_OUT);
data = data >> 1; // Prepare (shift) 'data' for the next cycle
if (PIND & (1 << DATA_IN)) data = data | 0x0800; // Put DATA_IN value in bit 'data11'
}
else { // Not yet our turn: just pass from IN to OUT
if (PIND & (1<< DATA_IN)) PORTD |= (1 << DATA_OUT); // Put in DATA_OUT the value of DATA_IN
else PORTD &= ~(1 << DATA_OUT);
cont++; // Update counter to continue waiting
}
}
void loop() {
}
Volver a Digital, Electricidad e Informática