Hi,
I have a TinyZero circuit that works as expected when connected using Proto Terminal Blocks shield, or using an Arduino UNO.
But it does not work when connected in the same way with Wirelings....! I'm trying to use GND, 3v3, and INT wires, along with an external pull-up resistor to get analog voltage values off my sensor.
Does Wireling have some internal processing that prohibits using this analog input in this way? can I turn that off? or am I doing something wrong?
My code:
//TerminalBlocksVsWireling
// 2022-09-15
#include <Wire.h>
#include <Wireling.h>
// boilerplate code to make serial monitor work with either arduino uno or tinycircuit's tinyzero
#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif
#define irdPin A0 // Corresponds to PORT# of Wireling used; or A0 of TerminalBlocks or Arduino UNO
int readValue = 0; // the IR sensor value, analog
void setup() {
SerialMonitorInterface.begin(9600);
// Start with a 3s delay, lighting external green LED for 3s.
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
delay(3000);
digitalWrite(LED_BUILTIN, LOW);
SerialMonitorInterface.println("");
SerialMonitorInterface.println("TerminalBlocksVsWireling");
pinMode(irdPin, INPUT);
}
void loop() {
readValue = analogRead(irdPin);
SerialMonitorInterface.print("IRD pin read value: ");
SerialMonitorInterface.println(readValue);
delay(500);
}
I took a Wireling cable and stripped the ends of the GND, 3V3, and INT (analog) and soldered them to wires to plug into a breadboard for testing.
On TerminalBlocks: I connect GND, VCC, and A0 to my protoboard.
On Wireling: I connect GND, 3V3, and INT from port 0 to my protoboard (equivalent).
The board has a couple of diodes and resistors as follows:
1. IR-Emitter diode with external current-limiting resistor: Just emits IR light:
VCC --------- 220ohmResist -------(+)anode_IRE_cathode(-)--------- GND
2. IR-Detector diode with external pullup resistor, connected to A0 between the resistor and the IRD:
VCC -----10kResist ---/-----(+)anode_IRD_cathode(-)------------------GND
/
A0
So,
When IRD is active (detects IR light), voltage on analog input A0 should be low voltage,
When IRD is inactive (detects no IR light), voltage on A0 should be a higher voltage.
Results:
Works perfectly with TerminalBlocks shield on TinyZero, or with Arduino UNO:
Low ~53 when IRD gets IR light
High ~700-800 when IR light blocked (using UNO 3.3V, High is ~500; that's fine)
But with Wireling shield, same connections: Not working!
Output is ~1 or 2, or 3 when IRD gets IR light
and is also ~1 or 2, or 3 when IR light blocked
I know that I can set an *internal* pull-up resistor on the analog input A0, but we don't want this -- we want to get an analog voltage value.
I found this earlier forum post about analog wireling use but it did not help here.
http://forum.tinycircuits.com/index.php?topic=2419.msg5307#msg5307Datasheets for the IRE and IRD diodes:
https://www.sparkfun.com/products/retired/241Thank you for any help!!