source: t29-www/physical-computing/ping-pong-led/ping-pong-led.ino @ 1113

Last change on this file since 1113 was 1113, checked in by heribert, 7 years ago

ersetzt....

File size: 875 bytes
Line 
1// ping-pong-LED mit bitSet und outShift (inkl. Toene)
2// Aufgabe 1a/b von Blatt 5
3
4int clockPin = 8;
5int latchPin = 9;
6int dataPin = 10;
7
8int leds = 0;
9
10void setup()
11{
12 pinMode(latchPin, OUTPUT);
13 pinMode(dataPin, OUTPUT); 
14 pinMode(clockPin, OUTPUT);
15}
16
17void loop()
18{
19  int frequenz = 200;
20 
21  for (int n = 0; n< 8; n++)
22  {
23    bitSet(leds, n);
24    updateShiftRegister();
25    tone(7, frequenz, 100);
26    delay(100);
27    frequenz=frequenz+50;
28    leds=0;
29    updateShiftRegister();   
30  }
31 
32frequenz=1000;
33
34  for (int n = 7; n>=0; n--)
35  {
36    bitSet(leds, n);
37    updateShiftRegister(); 
38    tone(7, frequenz, 100);
39    delay(100);
40    frequenz=frequenz-50;
41    leds=0;
42    updateShiftRegister();
43       
44  }
45}
46
47void updateShiftRegister()   
48{
49   digitalWrite(latchPin, LOW);
50   shiftOut(dataPin, clockPin, MSBFIRST, leds);
51   digitalWrite(latchPin, HIGH);
52}
53
54
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License