Well, I had everything working great on the Arduino Uno. Now I've converted it to work on a 5V Trinket.
Everything seems to work but the servo. The servo moves as the Trinket boots but nothing after.
/* Created by Nick Sebring: November 2017
This sketch is designed to activate a barcode reader by moving a chart in front of
the VCNL4010 I2C Proximity sensor. Thus triggering the servo to move a magnet over the sensor
in the handle of the barcode reader, activating the barcode readers infrared scanner. Thus avoiding
to reach across my desk and having to pull the trigger. How lazy can us humans be? Hahahaha
The SCL and SDA are connected to #0 & 2 of my 5V Trinket
*/
#include "Adafruit_SoftServo.h"
#include "Adafruit_VCNL4010.h"
#define SERVOPIN 4 // Servo control line (WHITE) on Trinket Pin #4
Adafruit_SoftServo TinyServo; //creates servo object
int pos = 0; // Variable to store the servo position
int a = 0; //just a variable to check the current value of sensePin
// Creating speed settings for servos; NOT used in this sketch
int servoDelay1 = 25; // Creates servo delay speed=25 in miliseconds
int servoDelay2 = 50; // Creates servo delay speed=50 in miliseconds
int servoDelay3 = 150; // Creates servo delay speed=150 in miliseconds
const int ledPin = 1;// LED on pin 1 to notify servo sketch is working
Adafruit_VCNL4010 vcnl;
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);// Set led off at start-up
TinyServo.attach(SERVOPIN); // attaches the servo
// Serial.begin(115200);
//Serial.println("VCNL4010 test");
if (! vcnl.begin()) {
//Serial.println("Sensor not found :(");
while (1);
}
}
void loop() {
if (vcnl.readProximity() > 2150)//2125 seems to be ideal without plastic cover
{
TinyServo.write(58);
digitalWrite(ledPin, HIGH);
}
else
{
TinyServo.write(25);
digitalWrite(ledPin, LOW);//
}
// Serial.print("Ambient: "); Serial.println(vcnl.readAmbient());
// Serial.print("Proximity: "); Serial.println(vcnl.readProximity());
}
Do you see any reason the servo doesn't move when my hand is over the sensor?
Thanks.
Hmm. Just ran the Trinket Knob sketch from Adafruit. The Servo works just fine. Back to rewiring.
Putting this thread on hold. Getting help from Adafruit forum. No need to cross hairs.