1 | #include <SPI.h>
|
2 | #include <Wire.h>
|
3 | #include <Adafruit_GFX.h>
|
4 | #include <Adafruit_SSD1306.h>
|
5 | #define DISPLAY_I2C_ADDRESS 0x3C
|
6 | #define DISPLAY_WIDTH 128
|
7 | #define DISPLAY_HEIGHT 64
|
8 | Adafruit_SSD1306 display(DISPLAY_WIDTH, DISPLAY_HEIGHT, &Wire, -1);
|
9 |
|
10 | /*#include "Arduino.h"
|
11 | #include "SoftwareSerial.h"
|
12 | #include "DFRobotDFPlayerMini.h"
|
13 | SoftwareSerial mySoftwareSerial(10, 11);
|
14 | DFRobotDFPlayerMini myDFPlayer;*/
|
15 |
|
16 | int motor = 6;
|
17 | int in1 = 9;
|
18 | int in2 = 8;
|
19 | int f = 0;
|
20 | int i = 0;
|
21 |
|
22 | void setup()
|
23 | {
|
24 | if (!display.begin(SSD1306_SWITCHCAPVCC, DISPLAY_I2C_ADDRESS))
|
25 | {
|
26 | Serial.println("SSD1306 nicht gefunden");
|
27 | for (;;);
|
28 | }
|
29 |
|
30 | /*if (!myDFPlayer.begin(mySoftwareSerial))
|
31 | {
|
32 | while(true);
|
33 | }
|
34 | myDFPlayer.volume(5);*/
|
35 |
|
36 | display.setTextSize(2);
|
37 | display.setTextColor(WHITE);
|
38 |
|
39 | pinMode(motor, OUTPUT);
|
40 | pinMode(in1, OUTPUT);
|
41 | pinMode(in2, OUTPUT);
|
42 | digitalWrite(in1, HIGH);
|
43 | digitalWrite(in2, LOW);
|
44 | anzeige();
|
45 | }
|
46 |
|
47 | void loop()
|
48 | {
|
49 | if (f == 0)
|
50 | {
|
51 | //myDFPlayer.playMp3Folder(0001);
|
52 | analogWrite(motor, 0);
|
53 | delay(3000);
|
54 |
|
55 | analogWrite(motor, 133);
|
56 | delay(5000);
|
57 |
|
58 | for (byte b = 0; b < 3; b++)
|
59 | {
|
60 | for (int i = 133; i <= 255; i++) //Beschleunigen
|
61 | {
|
62 | analogWrite(motor, i);
|
63 | delay(100);
|
64 | }
|
65 | delay(4000);
|
66 | for (int j = 255; j >= 133; j--) //Entschleunigen
|
67 | {
|
68 | analogWrite(motor, j);
|
69 | delay(80);
|
70 | }
|
71 | delay(2000);
|
72 | }
|
73 | analogWrite(motor, 0); //Motor aus
|
74 | f++;
|
75 | }
|
76 | }
|
77 |
|
78 | void anzeige()
|
79 | {
|
80 | display.clearDisplay();
|
81 | display.setCursor(0, 0);
|
82 |
|
83 | display.println(" Audi R8");
|
84 | display.println("PS: 560");
|
85 | display.println("KMH: 320");
|
86 | display.println("0-100: 3,3");
|
87 |
|
88 | display.display();
|
89 | }
|