Pozdrav trebao bi pomoc oko pisanja programa za smijer vjetra u arduinu. Koristim dva 74HC165 shift registra a mjerit cu 16 strana svijeta glavne,sporedne, sporedno sporedne. Kao detektori ce mi sluziti hall senzori. Moj problem je sad pisanje arduino koda za te shift registre. Ovo je primjer nedovrsenog koda ali neznam ni dali taj kod radi pa ako neko ima neke ideje ili se kuzi u arduino code pa da mi pomogne. Hvala :D
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the serial monitor
This example code is in the public domain.
*/
// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;
int my_sck=22;
int my_din=24;
int my_pl=26;
unsigned long my_long=0;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// make the pushbutton's pin an input:
// pinMode(pushButton, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(my_pl,HIGH);
digitalWrite(my_pl,LOW);
digitalWrite(my_pl,HIGH);
delay(1);
for(int i=0;i<32;i++)
{
digitalWrite(my_sck,HIGH);
my_long |= 1 << digitalRead(my_din);
digitalWrite(my_sck,LOW);
}
// print out the state of the button:
Serial.println(buttonState);
delay(1); // delay in between reads for stability
}