I am very new to hardware design and am making an optical detection circuit using a photodiode. I simply need to interface with the photodiode and save the output voltage values on Arduino IDE
Hardware setup:
- Photodiode (BPW21R) connected in transimpedance arrangement with 100K feedback resistor and OPA350 op amp
- Output signal from the transimpedance amplifier is connected to CH0 on the ADC (MCP3302)
- Op amp and ADC to be powered to +5V using Arduino Micro power pin
ADC <-> Arduino Micro Connections:
- VDD and VRef <-> +5V Power Pin
- CS/SHDN <-> RX_LED / SS
- DIN <-> MOSI
- DOUT <-> MISO
- CLK <-> SCK
My two questions are:
Are my connections between ADC and Arduino Micro correct to communicate by SPI protocol?
In Arduino IDE, how can I edit the code so that the Arduino Micro receives data from the ADC by SPI protocol and displays it in the serial monitor?
#include <SPI.h>
void setup() {
pinMode(SS, OUTPUT); pinMode(MISO, OUTPUT); digitalWrite(SS,HIGH); Serial.begin(115200);
}
void loop() { byte c;
digitalWrite(SS,LOW);Serial.println(analogRead(MISO)); digitalWrite(SS, HIGH); delay(100);
}