SlideShare a Scribd company logo
1 of 12
Download to read offline
What will be quantization step size in numbers and in voltage for this Arduino Code? Using 5V
const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int dataConv = sensorValue*(8.0/1024);
//write analog equvivalant data on led pins
switch(dataConv)
{
case 0: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 1: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 2: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 3: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 4: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 5: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 6: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
case 7: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
}
Serial.println(sensorValue); // print out the value you read:
Serial.println(dataConv);
delay(1000); // delay in between reads for stability
}
const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int dataConv = sensorValue*(8.0/1024);
//write analog equvivalant data on led pins
switch(dataConv)
{
case 0: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 1: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 2: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 3: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 4: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 5: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 6: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
case 7: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
}
Serial.println(sensorValue); // print out the value you read:
Serial.println(dataConv);
delay(1000); // delay in between reads for stability
}
Solution
// Random LED Dots - from noise source
// Ed Nisley - KE4ANU - September 2015
//----------
// Pin assignments
const byte PIN_HEARTBEAT = 8; // DO - heartbeat LED
const byte PIN_SYNC = A3; // DO - scope sync
const byte PIN_LATCH = 4; // DO - shift register latch clock
const byte PIN_DIMMING = 9; // AO - LED dimming control
// These are *hardware* SPI pins
const byte PIN_MOSI = 11; // DO - data to shift reg
const byte PIN_MISO = 12; // DI - data from shift reg - sampled noise input
const byte PIN_SCK = 13; // DO - shift clock to shift reg (also Arduino LED)
const byte PIN_SS = 10; // DO - -slave select (must be positive for SPI output)
//----------
// Constants
#define DISPLAY_MS 10000ul
//----------
// Globals
// Input noise bits can produce one of four possible conditions
// Use the von Neumann extractor, discarding 00 and 11 sequences
// https://en.wikipedia.org/wiki/Randomness_extractor#Von_Neumann_extractor
// Sampling interval depends on SPI data rate
// LSB arrives first, so it's the earliest sample
#define VNMASK_A 0x00000001
#define VNMASK_B 0x01000000
enum sample_t {VN_00,VN_01,VN_10,VN_11};
typedef struct {
byte BitCount; // number of bits accumulated so far
unsigned Bits; // random bits filled from low order upward
int Bias; // tallies 00 and 11 sequences to measure analog offset
unsigned SampleCount[4]; // number of samples in each bin
} random_t;
random_t RandomData;
// LED selects are high-active bits and low-active signals: flipped in UpdateLEDs()
// *exactly* one row select must be active in each element
typedef struct {
const byte Row;
byte ColR;
byte ColG;
byte ColB;
} leds_t;
// altering the number of rows & columns will require substantial code changes...
#define NUMROWS 8
#define NUMCOLS 8
leds_t LEDs[NUMROWS] = {
{0x80,0,0,0},
{0x40,0,0,0},
{0x20,0,0,0},
{0x10,0,0,0},
{0x08,0,0,0},
{0x04,0,0,0},
{0x02,0,0,0},
{0x01,0,0,0},
};
byte RowIndex;
#define LEDS_ON 0
#define LEDS_OFF 255
unsigned long MillisNow;
unsigned long DisplayBase;
//-- Helper routine for printf()
int s_putc(char c, FILE *t) {
Serial.write(c);
}
//-- Useful stuff
// Free RAM space monitor
// From http://playground.arduino.cc/Code/AvailableMemory
uint8_t * heapptr, * stackptr;
void check_mem() {
stackptr = (uint8_t *)malloc(4); // use stackptr temporarily
heapptr = stackptr; // save value of heap pointer
free(stackptr); // free up the memory again (sets stackptr to 0)
stackptr = (uint8_t *)(SP); // save value of stack pointer
}
void TogglePin(char bitpin) {
digitalWrite(bitpin,!digitalRead(bitpin)); // toggle the bit based on previous output
}
void PulsePin(char bitpin) {
TogglePin(bitpin);
TogglePin(bitpin);
}
//---------
//-- SPI utilities
void EnableSPI(void) {
digitalWrite(PIN_SS,HIGH); // make sure this is high!
SPCR |= 1 << SPE;
}
void DisableSPI(void) {
SPCR &= ~(1 << SPE);
}
void WaitSPIF(void) {
while (! (SPSR & (1 << SPIF))) {
// TogglePin(PIN_HEARTBEAT);
continue;
}
}
byte SendRecSPI(byte DataByte) { // send one byte, get another in exchange
SPDR = DataByte;
WaitSPIF();
return SPDR; // SPIF will be cleared
}
//---------------
// Update LED shift registers with new data
// Returns noise data shifted in through MISO bit
unsigned long UpdateLEDs(byte i) {
unsigned long NoiseData = 0ul;
NoiseData |= (unsigned long) SendRecSPI(~LEDs[i].ColB); // correct for low-active
outputs
NoiseData |= ((unsigned long) SendRecSPI(~LEDs[i].ColG)) << 8;
NoiseData |= ((unsigned long) SendRecSPI(~LEDs[i].ColR)) << 16;
NoiseData |= ((unsigned long) SendRecSPI(~LEDs[i].Row)) << 24;
analogWrite(PIN_DIMMING,LEDS_OFF); // turn off LED to quench current
PulsePin(PIN_LATCH); // make new shift reg contents visible
analogWrite(PIN_DIMMING,LEDS_ON);
return NoiseData;
}
//---------------
// Extract random data from sampled noise input
// ... tuck it into the global bit structure
// Returns von Neumann status of the sample
byte ExtractRandomBit(unsigned long RawSample) {
byte RetVal;
switch (RawSample & (VNMASK_A | VNMASK_B)) {
case 0: // 00 - discard
RetVal = VN_00;
RandomData.Bias--;
break;
case VNMASK_A: // 10 - true
RetVal = VN_10;
RandomData.BitCount++;
RandomData.Bits = (RandomData.Bits << 1) | 1;
break;
case VNMASK_B: // 01 - false
RetVal = VN_01;
RandomData.BitCount++;
RandomData.Bits = RandomData.Bits << 1;
break;
case (VNMASK_A | VNMASK_B): // 11 - discard
RetVal = VN_11;
RandomData.Bias++;
break;
}
RandomData.Bias = constrain(RandomData.Bias,-9999,9999);
RandomData.SampleCount[RetVal]++;
RandomData.SampleCount[RetVal] =
constrain(RandomData.SampleCount[RetVal],0,63999);
return RetVal;
}
//---------------
// Set LED from random bits
// Assumes the Value contains at least nine low-order random bits
// On average, this leaves the LED unchanged for 1/8 of the calls...
void SetLED(unsigned Value) {
byte Row = Value & 0x07;
byte Col = (Value >> 3) & 0x07;
byte Color = (Value >> 6) & 0x07;
byte BitMask = (0x80 >> Col);
// printf("%u %u %u %u  ",Row,Col,Color,BitMask);
LEDs[Row].ColR &= ~BitMask;
LEDs[Row].ColR |= (Color & 0x04) ? BitMask : 0;
LEDs[Row].ColG &= ~BitMask;
LEDs[Row].ColG |= (Color & 0x02) ? BitMask : 0;
LEDs[Row].ColB &= ~BitMask;
LEDs[Row].ColB |= (Color & 0x01) ? BitMask : 0;
}
//------------------
// Set things up
void setup() {
pinMode(PIN_HEARTBEAT,OUTPUT);
digitalWrite(PIN_HEARTBEAT,HIGH); // show we arrived
pinMode(PIN_SYNC,OUTPUT);
digitalWrite(PIN_SYNC,LOW);
pinMode(PIN_MOSI,OUTPUT); // SPI-as-output is not strictly necessary
digitalWrite(PIN_MOSI,LOW);
pinMode(PIN_SCK,OUTPUT);
digitalWrite(PIN_SCK,LOW);
pinMode(PIN_SS,OUTPUT);
digitalWrite(PIN_SS,HIGH); // OUTPUT + HIGH is required to make SPI output
work
pinMode(PIN_LATCH,OUTPUT);
digitalWrite(PIN_LATCH,LOW);
Serial.begin(57600);
fdevopen(&s_putc,0); // set up serial output for printf()
printf("Noisy LED Dots  Ed Nisley - KE4ZNU - September 2015  ");
//-- Set up SPI hardware
// LSB of SPCR set bit clock speed:
// 00 = f/4
// 01 = f/16
// 10 = f/64
// 11 = f/128
SPCR = B01110011; // Auto SPI: no int, enable, LSB first, master, + edge,
leading, speed
SPSR = B00000000; // not double data rate
EnableSPI(); // turn on the SPI hardware
SendRecSPI(0); // set valid data in shift registers: select Row 0, all LEDs off
//-- Dimming pin must use fast PWM to avoid beat flicker with LED refresh rate
// Timer 1: PWM 9 PWM 10
analogWrite(PIN_DIMMING,LEDS_OFF); // disable column drive (hardware pulled it low
before startup)
TCCR1A = B10000001; // Mode 5 = fast 8-bit PWM with TOP=FF
TCCR1B = B00001001; // ... WGM, 1:1 clock scale -> 64 kHz
//-- lamp test: send a white flash through all LEDs
// collects noise data to get some randomness going
printf("Lamp test begins: white flash each LED...");
digitalWrite(PIN_HEARTBEAT,LOW); // turn off while panel blinks
analogWrite(PIN_DIMMING,LEDS_ON); // enable column drive
for (byte i=0; i> j;
for (byte k=0; k= NUMROWS) { // set up LED row index for this pass
RowIndex = 0;
PulsePin(PIN_SYNC);
}
if ((MillisNow - DisplayBase) >= DISPLAY_MS) {
analogWrite(PIN_DIMMING,LEDS_OFF); // turn off LED to prevent bright glitch
printf("Bias: %5d of %5u - %5u %5u %5u %5u  ",
RandomData.Bias,
RandomData.SampleCount[VN_00] + RandomData.SampleCount[VN_11],
RandomData.SampleCount[0],
RandomData.SampleCount[1],
RandomData.SampleCount[2],
RandomData.SampleCount[3]
);
RandomData.Bias = 0;
for (byte i=0; i<4; i++) {
RandomData.SampleCount[i] = 0;
}
// check_mem();
// printf("SP: %u HP: %u Free RAM: %u  ",stackptr,heapptr,stackptr - heapptr);
DisplayBase = MillisNow;
}
// Update one LED row per pass, get at most one random bit
ThisBit = ExtractRandomBit(UpdateLEDs(RowIndex++));
// Update the heartbeat LED to show bit validity
switch (ThisBit) {
case VN_00:
case VN_11:
digitalWrite(PIN_HEARTBEAT,HIGH);
break;
case VN_01:
case VN_10:
digitalWrite(PIN_HEARTBEAT,LOW);
break;
}
// If we have enough random data, twiddle one LED
if (RandomData.BitCount >= 9) {
// analogWrite(PIN_DIMMING,LEDS_OFF); // turn off LED array to prevent bright
glitch
SetLED(RandomData.Bits);
RandomData.BitCount = 0;
RandomData.Bits = 0;
}
digitalWrite(PIN_HEARTBEAT,LOW);
}

More Related Content

Similar to What will be quantization step size in numbers and in voltage for th.pdf

PROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdfPROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdfvidhyalakshmi153619
 
Hardware interfacing basics using AVR
Hardware interfacing basics using AVRHardware interfacing basics using AVR
Hardware interfacing basics using AVRMohamed Abdallah
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuatorsEueung Mulyana
 
Arduino: Analog I/O
Arduino: Analog I/OArduino: Analog I/O
Arduino: Analog I/OJune-Hao Hou
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdfJayanthi Kannan MK
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalTony Olsson.
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalTony Olsson.
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IOT Academy
 
01_DIGITAL IO.pptx
01_DIGITAL IO.pptx01_DIGITAL IO.pptx
01_DIGITAL IO.pptxssuser593a2d
 
Introduction to Arduino and Circuits
Introduction to Arduino and CircuitsIntroduction to Arduino and Circuits
Introduction to Arduino and CircuitsJason Griffey
 
04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)antonio michua
 
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docxmayank272369
 
CC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleCC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleAarya Technologies
 

Similar to What will be quantization step size in numbers and in voltage for th.pdf (20)

LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
PROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdfPROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdf
 
Hardware interfacing basics using AVR
Hardware interfacing basics using AVRHardware interfacing basics using AVR
Hardware interfacing basics using AVR
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuators
 
Arduino: Analog I/O
Arduino: Analog I/OArduino: Analog I/O
Arduino: Analog I/O
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
 
01_DIGITAL IO.pptx
01_DIGITAL IO.pptx01_DIGITAL IO.pptx
01_DIGITAL IO.pptx
 
Arduino Workshop 2011.05.31
Arduino Workshop 2011.05.31Arduino Workshop 2011.05.31
Arduino Workshop 2011.05.31
 
Introduction to Arduino and Circuits
Introduction to Arduino and CircuitsIntroduction to Arduino and Circuits
Introduction to Arduino and Circuits
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)
 
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx# peripheral registers  .equ PWR_BASE0x40007000    .equ PWR_CR0x00  .docx
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
 
Avr report
Avr reportAvr report
Avr report
 
Day1
Day1Day1
Day1
 
Arduino intro.pptx
Arduino intro.pptxArduino intro.pptx
Arduino intro.pptx
 
Product catlog
Product catlogProduct catlog
Product catlog
 
CC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleCC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver Module
 

More from SIGMATAX1

Consider a binary search tree T with nodes containing the four fields.pdf
Consider a binary search tree T with nodes containing the four fields.pdfConsider a binary search tree T with nodes containing the four fields.pdf
Consider a binary search tree T with nodes containing the four fields.pdfSIGMATAX1
 
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdfBased on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdfSIGMATAX1
 
Comparecontrast the following classes of hormones by identifying thr.pdf
Comparecontrast the following classes of hormones by identifying thr.pdfComparecontrast the following classes of hormones by identifying thr.pdf
Comparecontrast the following classes of hormones by identifying thr.pdfSIGMATAX1
 
Why does the incidence of acute disease decrease with ageSoluti.pdf
Why does the incidence of acute disease decrease with ageSoluti.pdfWhy does the incidence of acute disease decrease with ageSoluti.pdf
Why does the incidence of acute disease decrease with ageSoluti.pdfSIGMATAX1
 
White eye color in Drosophila was discovered to be sex linked by Tho.pdf
White eye color in Drosophila was discovered to be sex linked by Tho.pdfWhite eye color in Drosophila was discovered to be sex linked by Tho.pdf
White eye color in Drosophila was discovered to be sex linked by Tho.pdfSIGMATAX1
 
Which of the following protons would you NOT expect to find embedded .pdf
Which of the following protons would you NOT expect to find embedded .pdfWhich of the following protons would you NOT expect to find embedded .pdf
Which of the following protons would you NOT expect to find embedded .pdfSIGMATAX1
 
Which of these characteristics distinguishes angiosperms from other .pdf
Which of these characteristics distinguishes angiosperms from other .pdfWhich of these characteristics distinguishes angiosperms from other .pdf
Which of these characteristics distinguishes angiosperms from other .pdfSIGMATAX1
 
Which of the following is MOST responsible for maintaining the doubl.pdf
Which of the following is MOST responsible for maintaining the doubl.pdfWhich of the following is MOST responsible for maintaining the doubl.pdf
Which of the following is MOST responsible for maintaining the doubl.pdfSIGMATAX1
 
What are the role of environmental factors on transpiration and h.pdf
What are the role of environmental factors on transpiration and h.pdfWhat are the role of environmental factors on transpiration and h.pdf
What are the role of environmental factors on transpiration and h.pdfSIGMATAX1
 
What is the need for a shadow page table (One or two brief sentences.pdf
What is the need for a shadow page table (One or two brief sentences.pdfWhat is the need for a shadow page table (One or two brief sentences.pdf
What is the need for a shadow page table (One or two brief sentences.pdfSIGMATAX1
 
What step of protein synthesis is shown in the figure elongation st.pdf
What step of protein synthesis is shown in the figure  elongation st.pdfWhat step of protein synthesis is shown in the figure  elongation st.pdf
What step of protein synthesis is shown in the figure elongation st.pdfSIGMATAX1
 
Water is forced through a contraction causing low pressure. The wat.pdf
Water is forced through a contraction causing low pressure. The wat.pdfWater is forced through a contraction causing low pressure. The wat.pdf
Water is forced through a contraction causing low pressure. The wat.pdfSIGMATAX1
 
Using a PIC 18 Write a time overflow interrupt routine that detects .pdf
Using a PIC 18 Write a time overflow interrupt routine that detects .pdfUsing a PIC 18 Write a time overflow interrupt routine that detects .pdf
Using a PIC 18 Write a time overflow interrupt routine that detects .pdfSIGMATAX1
 
The three types of mixtures are and The weak bond forming a bridge .pdf
The three types of mixtures are  and  The weak bond forming a bridge .pdfThe three types of mixtures are  and  The weak bond forming a bridge .pdf
The three types of mixtures are and The weak bond forming a bridge .pdfSIGMATAX1
 
Some commercial airplanes recirculate approximately 50 of the cabin .pdf
Some commercial airplanes recirculate approximately 50 of the cabin .pdfSome commercial airplanes recirculate approximately 50 of the cabin .pdf
Some commercial airplanes recirculate approximately 50 of the cabin .pdfSIGMATAX1
 
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdfSolve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdfSIGMATAX1
 
Required 1. Briefly describe different computer controls available .pdf
Required 1. Briefly describe different computer controls available .pdfRequired 1. Briefly describe different computer controls available .pdf
Required 1. Briefly describe different computer controls available .pdfSIGMATAX1
 
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdfa. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdfSIGMATAX1
 
Proponents of decentralized forms of socialism usually supportA co.pdf
Proponents of decentralized forms of socialism usually supportA co.pdfProponents of decentralized forms of socialism usually supportA co.pdf
Proponents of decentralized forms of socialism usually supportA co.pdfSIGMATAX1
 
Please convert the following C code to assembly Y86int i,j; ......pdf
Please convert the following C code to assembly Y86int i,j; ......pdfPlease convert the following C code to assembly Y86int i,j; ......pdf
Please convert the following C code to assembly Y86int i,j; ......pdfSIGMATAX1
 

More from SIGMATAX1 (20)

Consider a binary search tree T with nodes containing the four fields.pdf
Consider a binary search tree T with nodes containing the four fields.pdfConsider a binary search tree T with nodes containing the four fields.pdf
Consider a binary search tree T with nodes containing the four fields.pdf
 
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdfBased on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
Based on the articleWhy It Is Time to Look Beyond Algal Genes in P.pdf
 
Comparecontrast the following classes of hormones by identifying thr.pdf
Comparecontrast the following classes of hormones by identifying thr.pdfComparecontrast the following classes of hormones by identifying thr.pdf
Comparecontrast the following classes of hormones by identifying thr.pdf
 
Why does the incidence of acute disease decrease with ageSoluti.pdf
Why does the incidence of acute disease decrease with ageSoluti.pdfWhy does the incidence of acute disease decrease with ageSoluti.pdf
Why does the incidence of acute disease decrease with ageSoluti.pdf
 
White eye color in Drosophila was discovered to be sex linked by Tho.pdf
White eye color in Drosophila was discovered to be sex linked by Tho.pdfWhite eye color in Drosophila was discovered to be sex linked by Tho.pdf
White eye color in Drosophila was discovered to be sex linked by Tho.pdf
 
Which of the following protons would you NOT expect to find embedded .pdf
Which of the following protons would you NOT expect to find embedded .pdfWhich of the following protons would you NOT expect to find embedded .pdf
Which of the following protons would you NOT expect to find embedded .pdf
 
Which of these characteristics distinguishes angiosperms from other .pdf
Which of these characteristics distinguishes angiosperms from other .pdfWhich of these characteristics distinguishes angiosperms from other .pdf
Which of these characteristics distinguishes angiosperms from other .pdf
 
Which of the following is MOST responsible for maintaining the doubl.pdf
Which of the following is MOST responsible for maintaining the doubl.pdfWhich of the following is MOST responsible for maintaining the doubl.pdf
Which of the following is MOST responsible for maintaining the doubl.pdf
 
What are the role of environmental factors on transpiration and h.pdf
What are the role of environmental factors on transpiration and h.pdfWhat are the role of environmental factors on transpiration and h.pdf
What are the role of environmental factors on transpiration and h.pdf
 
What is the need for a shadow page table (One or two brief sentences.pdf
What is the need for a shadow page table (One or two brief sentences.pdfWhat is the need for a shadow page table (One or two brief sentences.pdf
What is the need for a shadow page table (One or two brief sentences.pdf
 
What step of protein synthesis is shown in the figure elongation st.pdf
What step of protein synthesis is shown in the figure  elongation st.pdfWhat step of protein synthesis is shown in the figure  elongation st.pdf
What step of protein synthesis is shown in the figure elongation st.pdf
 
Water is forced through a contraction causing low pressure. The wat.pdf
Water is forced through a contraction causing low pressure. The wat.pdfWater is forced through a contraction causing low pressure. The wat.pdf
Water is forced through a contraction causing low pressure. The wat.pdf
 
Using a PIC 18 Write a time overflow interrupt routine that detects .pdf
Using a PIC 18 Write a time overflow interrupt routine that detects .pdfUsing a PIC 18 Write a time overflow interrupt routine that detects .pdf
Using a PIC 18 Write a time overflow interrupt routine that detects .pdf
 
The three types of mixtures are and The weak bond forming a bridge .pdf
The three types of mixtures are  and  The weak bond forming a bridge .pdfThe three types of mixtures are  and  The weak bond forming a bridge .pdf
The three types of mixtures are and The weak bond forming a bridge .pdf
 
Some commercial airplanes recirculate approximately 50 of the cabin .pdf
Some commercial airplanes recirculate approximately 50 of the cabin .pdfSome commercial airplanes recirculate approximately 50 of the cabin .pdf
Some commercial airplanes recirculate approximately 50 of the cabin .pdf
 
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdfSolve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
Solve for 02 sin 2+sin 5=0. Separate your answers with commas.pdf
 
Required 1. Briefly describe different computer controls available .pdf
Required 1. Briefly describe different computer controls available .pdfRequired 1. Briefly describe different computer controls available .pdf
Required 1. Briefly describe different computer controls available .pdf
 
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdfa. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
a. What is Snort [1]b. According to “Snort Users Manual” (downloa.pdf
 
Proponents of decentralized forms of socialism usually supportA co.pdf
Proponents of decentralized forms of socialism usually supportA co.pdfProponents of decentralized forms of socialism usually supportA co.pdf
Proponents of decentralized forms of socialism usually supportA co.pdf
 
Please convert the following C code to assembly Y86int i,j; ......pdf
Please convert the following C code to assembly Y86int i,j; ......pdfPlease convert the following C code to assembly Y86int i,j; ......pdf
Please convert the following C code to assembly Y86int i,j; ......pdf
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 

What will be quantization step size in numbers and in voltage for th.pdf

  • 1. What will be quantization step size in numbers and in voltage for this Arduino Code? Using 5V const int led1 = 2; const int led2 = 3; const int led3 = 4; void setup() { pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); int dataConv = sensorValue*(8.0/1024); //write analog equvivalant data on led pins switch(dataConv) { case 0: { digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); break; } case 1: { digitalWrite(led1,HIGH); digitalWrite(led2,LOW); digitalWrite(led3,LOW); break; } case 2: { digitalWrite(led1,LOW); digitalWrite(led2,HIGH); digitalWrite(led3,LOW);
  • 2. break; } case 3: { digitalWrite(led1,HIGH); digitalWrite(led2,HIGH); digitalWrite(led3,LOW); break; } case 4: { digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,HIGH); break; } case 5: { digitalWrite(led1,HIGH); digitalWrite(led2,LOW); digitalWrite(led3,HIGH); break; } case 6: { digitalWrite(led1,LOW); digitalWrite(led2,HIGH); digitalWrite(led3,HIGH); break; } case 7: { digitalWrite(led1,HIGH); digitalWrite(led2,HIGH); digitalWrite(led3,HIGH); break; } } Serial.println(sensorValue); // print out the value you read: Serial.println(dataConv);
  • 3. delay(1000); // delay in between reads for stability } const int led1 = 2; const int led2 = 3; const int led3 = 4; void setup() { pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); int dataConv = sensorValue*(8.0/1024); //write analog equvivalant data on led pins switch(dataConv) { case 0: { digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); break; } case 1: { digitalWrite(led1,HIGH); digitalWrite(led2,LOW); digitalWrite(led3,LOW); break; } case 2: { digitalWrite(led1,LOW); digitalWrite(led2,HIGH); digitalWrite(led3,LOW);
  • 4. break; } case 3: { digitalWrite(led1,HIGH); digitalWrite(led2,HIGH); digitalWrite(led3,LOW); break; } case 4: { digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,HIGH); break; } case 5: { digitalWrite(led1,HIGH); digitalWrite(led2,LOW); digitalWrite(led3,HIGH); break; } case 6: { digitalWrite(led1,LOW); digitalWrite(led2,HIGH); digitalWrite(led3,HIGH); break; } case 7: { digitalWrite(led1,HIGH); digitalWrite(led2,HIGH); digitalWrite(led3,HIGH); break; } } Serial.println(sensorValue); // print out the value you read: Serial.println(dataConv);
  • 5. delay(1000); // delay in between reads for stability } Solution // Random LED Dots - from noise source // Ed Nisley - KE4ANU - September 2015 //---------- // Pin assignments const byte PIN_HEARTBEAT = 8; // DO - heartbeat LED const byte PIN_SYNC = A3; // DO - scope sync const byte PIN_LATCH = 4; // DO - shift register latch clock const byte PIN_DIMMING = 9; // AO - LED dimming control // These are *hardware* SPI pins const byte PIN_MOSI = 11; // DO - data to shift reg const byte PIN_MISO = 12; // DI - data from shift reg - sampled noise input const byte PIN_SCK = 13; // DO - shift clock to shift reg (also Arduino LED) const byte PIN_SS = 10; // DO - -slave select (must be positive for SPI output) //---------- // Constants #define DISPLAY_MS 10000ul //---------- // Globals // Input noise bits can produce one of four possible conditions // Use the von Neumann extractor, discarding 00 and 11 sequences // https://en.wikipedia.org/wiki/Randomness_extractor#Von_Neumann_extractor // Sampling interval depends on SPI data rate // LSB arrives first, so it's the earliest sample #define VNMASK_A 0x00000001 #define VNMASK_B 0x01000000 enum sample_t {VN_00,VN_01,VN_10,VN_11}; typedef struct { byte BitCount; // number of bits accumulated so far unsigned Bits; // random bits filled from low order upward int Bias; // tallies 00 and 11 sequences to measure analog offset unsigned SampleCount[4]; // number of samples in each bin
  • 6. } random_t; random_t RandomData; // LED selects are high-active bits and low-active signals: flipped in UpdateLEDs() // *exactly* one row select must be active in each element typedef struct { const byte Row; byte ColR; byte ColG; byte ColB; } leds_t; // altering the number of rows & columns will require substantial code changes... #define NUMROWS 8 #define NUMCOLS 8 leds_t LEDs[NUMROWS] = { {0x80,0,0,0}, {0x40,0,0,0}, {0x20,0,0,0}, {0x10,0,0,0}, {0x08,0,0,0}, {0x04,0,0,0}, {0x02,0,0,0}, {0x01,0,0,0}, }; byte RowIndex; #define LEDS_ON 0 #define LEDS_OFF 255 unsigned long MillisNow; unsigned long DisplayBase; //-- Helper routine for printf() int s_putc(char c, FILE *t) { Serial.write(c); } //-- Useful stuff // Free RAM space monitor // From http://playground.arduino.cc/Code/AvailableMemory uint8_t * heapptr, * stackptr;
  • 7. void check_mem() { stackptr = (uint8_t *)malloc(4); // use stackptr temporarily heapptr = stackptr; // save value of heap pointer free(stackptr); // free up the memory again (sets stackptr to 0) stackptr = (uint8_t *)(SP); // save value of stack pointer } void TogglePin(char bitpin) { digitalWrite(bitpin,!digitalRead(bitpin)); // toggle the bit based on previous output } void PulsePin(char bitpin) { TogglePin(bitpin); TogglePin(bitpin); } //--------- //-- SPI utilities void EnableSPI(void) { digitalWrite(PIN_SS,HIGH); // make sure this is high! SPCR |= 1 << SPE; } void DisableSPI(void) { SPCR &= ~(1 << SPE); } void WaitSPIF(void) { while (! (SPSR & (1 << SPIF))) { // TogglePin(PIN_HEARTBEAT); continue; } } byte SendRecSPI(byte DataByte) { // send one byte, get another in exchange SPDR = DataByte; WaitSPIF(); return SPDR; // SPIF will be cleared } //--------------- // Update LED shift registers with new data // Returns noise data shifted in through MISO bit
  • 8. unsigned long UpdateLEDs(byte i) { unsigned long NoiseData = 0ul; NoiseData |= (unsigned long) SendRecSPI(~LEDs[i].ColB); // correct for low-active outputs NoiseData |= ((unsigned long) SendRecSPI(~LEDs[i].ColG)) << 8; NoiseData |= ((unsigned long) SendRecSPI(~LEDs[i].ColR)) << 16; NoiseData |= ((unsigned long) SendRecSPI(~LEDs[i].Row)) << 24; analogWrite(PIN_DIMMING,LEDS_OFF); // turn off LED to quench current PulsePin(PIN_LATCH); // make new shift reg contents visible analogWrite(PIN_DIMMING,LEDS_ON); return NoiseData; } //--------------- // Extract random data from sampled noise input // ... tuck it into the global bit structure // Returns von Neumann status of the sample byte ExtractRandomBit(unsigned long RawSample) { byte RetVal; switch (RawSample & (VNMASK_A | VNMASK_B)) { case 0: // 00 - discard RetVal = VN_00; RandomData.Bias--; break; case VNMASK_A: // 10 - true RetVal = VN_10; RandomData.BitCount++; RandomData.Bits = (RandomData.Bits << 1) | 1; break; case VNMASK_B: // 01 - false RetVal = VN_01; RandomData.BitCount++; RandomData.Bits = RandomData.Bits << 1; break;
  • 9. case (VNMASK_A | VNMASK_B): // 11 - discard RetVal = VN_11; RandomData.Bias++; break; } RandomData.Bias = constrain(RandomData.Bias,-9999,9999); RandomData.SampleCount[RetVal]++; RandomData.SampleCount[RetVal] = constrain(RandomData.SampleCount[RetVal],0,63999); return RetVal; } //--------------- // Set LED from random bits // Assumes the Value contains at least nine low-order random bits // On average, this leaves the LED unchanged for 1/8 of the calls... void SetLED(unsigned Value) { byte Row = Value & 0x07; byte Col = (Value >> 3) & 0x07; byte Color = (Value >> 6) & 0x07; byte BitMask = (0x80 >> Col); // printf("%u %u %u %u ",Row,Col,Color,BitMask); LEDs[Row].ColR &= ~BitMask; LEDs[Row].ColR |= (Color & 0x04) ? BitMask : 0; LEDs[Row].ColG &= ~BitMask; LEDs[Row].ColG |= (Color & 0x02) ? BitMask : 0; LEDs[Row].ColB &= ~BitMask; LEDs[Row].ColB |= (Color & 0x01) ? BitMask : 0; } //------------------
  • 10. // Set things up void setup() { pinMode(PIN_HEARTBEAT,OUTPUT); digitalWrite(PIN_HEARTBEAT,HIGH); // show we arrived pinMode(PIN_SYNC,OUTPUT); digitalWrite(PIN_SYNC,LOW); pinMode(PIN_MOSI,OUTPUT); // SPI-as-output is not strictly necessary digitalWrite(PIN_MOSI,LOW); pinMode(PIN_SCK,OUTPUT); digitalWrite(PIN_SCK,LOW); pinMode(PIN_SS,OUTPUT); digitalWrite(PIN_SS,HIGH); // OUTPUT + HIGH is required to make SPI output work pinMode(PIN_LATCH,OUTPUT); digitalWrite(PIN_LATCH,LOW); Serial.begin(57600); fdevopen(&s_putc,0); // set up serial output for printf() printf("Noisy LED Dots Ed Nisley - KE4ZNU - September 2015 "); //-- Set up SPI hardware // LSB of SPCR set bit clock speed: // 00 = f/4 // 01 = f/16 // 10 = f/64 // 11 = f/128 SPCR = B01110011; // Auto SPI: no int, enable, LSB first, master, + edge, leading, speed SPSR = B00000000; // not double data rate EnableSPI(); // turn on the SPI hardware SendRecSPI(0); // set valid data in shift registers: select Row 0, all LEDs off
  • 11. //-- Dimming pin must use fast PWM to avoid beat flicker with LED refresh rate // Timer 1: PWM 9 PWM 10 analogWrite(PIN_DIMMING,LEDS_OFF); // disable column drive (hardware pulled it low before startup) TCCR1A = B10000001; // Mode 5 = fast 8-bit PWM with TOP=FF TCCR1B = B00001001; // ... WGM, 1:1 clock scale -> 64 kHz //-- lamp test: send a white flash through all LEDs // collects noise data to get some randomness going printf("Lamp test begins: white flash each LED..."); digitalWrite(PIN_HEARTBEAT,LOW); // turn off while panel blinks analogWrite(PIN_DIMMING,LEDS_ON); // enable column drive for (byte i=0; i> j; for (byte k=0; k= NUMROWS) { // set up LED row index for this pass RowIndex = 0; PulsePin(PIN_SYNC); } if ((MillisNow - DisplayBase) >= DISPLAY_MS) { analogWrite(PIN_DIMMING,LEDS_OFF); // turn off LED to prevent bright glitch printf("Bias: %5d of %5u - %5u %5u %5u %5u ", RandomData.Bias, RandomData.SampleCount[VN_00] + RandomData.SampleCount[VN_11], RandomData.SampleCount[0], RandomData.SampleCount[1], RandomData.SampleCount[2], RandomData.SampleCount[3] ); RandomData.Bias = 0; for (byte i=0; i<4; i++) { RandomData.SampleCount[i] = 0; } // check_mem(); // printf("SP: %u HP: %u Free RAM: %u ",stackptr,heapptr,stackptr - heapptr);
  • 12. DisplayBase = MillisNow; } // Update one LED row per pass, get at most one random bit ThisBit = ExtractRandomBit(UpdateLEDs(RowIndex++)); // Update the heartbeat LED to show bit validity switch (ThisBit) { case VN_00: case VN_11: digitalWrite(PIN_HEARTBEAT,HIGH); break; case VN_01: case VN_10: digitalWrite(PIN_HEARTBEAT,LOW); break; } // If we have enough random data, twiddle one LED if (RandomData.BitCount >= 9) { // analogWrite(PIN_DIMMING,LEDS_OFF); // turn off LED array to prevent bright glitch SetLED(RandomData.Bits); RandomData.BitCount = 0; RandomData.Bits = 0; } digitalWrite(PIN_HEARTBEAT,LOW); }