Merge branch 'main' of https://gitty.informatik.hs-mannheim.de/2021544/GMTROM
commit
605e592f3d
|
@ -0,0 +1,33 @@
|
||||||
|
const int adcPin = A0; // ADC-Pin
|
||||||
|
const int serialBaudRate = 115200; // Baudrate des seriellen Monitors
|
||||||
|
const float toggleDelay = 0.2; // Verzögerung zwischen dem Umschalten der Bits, in Mikrosekunden
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(serialBaudRate); // Starten des seriellen Monitors
|
||||||
|
analogReadResolution(12);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
uint32_t buffer[8] = {0}; // Initialisierung des Puffer-Arrays mit Nullen
|
||||||
|
uint8_t bitCount = 0; // Anzahl der erzeugten Bits
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
uint32_t randomValue = 0; // Initialisierung der zufälligen Zahl
|
||||||
|
|
||||||
|
while (bitCount < 32) {
|
||||||
|
uint16_t adcValue = analogRead(adcPin); // Lesen des ADC-Werts
|
||||||
|
uint32_t newBit = adcValue & 0x01; // Extrahieren des LSB aus dem ADC-Wert
|
||||||
|
randomValue = (randomValue << 1) | newBit; // Hinzufügen des neuen Bits an das LSB
|
||||||
|
bitCount++; // Inkrementierung der Anzahl der erzeugten Bits
|
||||||
|
delay(toggleDelay); // Verzögerung
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[i] = randomValue; // Speichern des zufälligen Werts im Puffer-Array
|
||||||
|
bitCount = 0; // Zurücksetzen der Anzahl der erzeugten Bits
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
Serial.write((byte*)&buffer[i], sizeof(buffer[i])); // Ausgabe der erzeugten 32-Bit-Werte als Bitfolge
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue