#define LATCH_PIN 5 // CI 12
#define CLOCK_PIN 6 // CI 11
#define DATA_PIN 4 // CI 14
void setup() {
pinMode(LATCH_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(DATA_PIN, OUTPUT);
}
void loop()
{
digitalWrite(LATCH_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, 0b11111111);
digitalWrite(LATCH_PIN, HIGH);
delay(1000);
}
int sensorValue = 0;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop()
{
sensorValue = analogRead(A0);
Serial.println(sensorValue);
analogWrite(9, map(sensorValue, 0, 1023, 0, 255));
analogWrite(10, map(sensorValue, 0, 1023, 0, 255));
delay(100);
}
Do'stlaringiz bilan baham: |