• aditya mehrotra.

filament updates: making the encoder work with wiring and everything [updates]

Yes so, today we're also trying to get the encoder working in preparation for getting the system working. That means making the motor move and making the encoder move as well. So here we go:

With a few very simple lines of code, we got the encoder working thanks to our friends from online at instructables.

/*     Arduino Rotary Encoder Tutorial
 *  by Dejan Nedelkovski, www.HowToMechatronics.com
 #define outputA 6
 #define outputB 7

 int counter = 0; 
 int aState;
 int aLastState;  

 void setup() { 
   pinMode (outputA,INPUT);
   pinMode (outputB,INPUT);
   Serial.begin (9600);
   // Reads the initial state of the outputA
   aLastState = digitalRead(outputA);   

 void loop() { 
   aState = digitalRead(outputA); // Reads the "current" state of the outputA
   // If the previous and the current state of the outputA are different, that means a Pulse has occured
   if (aState != aLastState){     
     // If the outputB state is different to the outputA state, that means the encoder is rotating clockwise
     if (digitalRead(outputB) != aState) { 
       counter ++;
     } else {
       counter --;
     Serial.print("Position: ");
   aLastState = aState; // Updates the previous state of the outputA with the current state

And now we're getting pulses! We're going to run some tests to see how many pulses are in one rotation but nonetheless we're just getting started with this whole thing. I'm concerned about the number of things we're powering from the arduino though. The display doesn't seem to be very happy at the moment - and if I unplug the encoder that doesn't fix it either. So something funny is going on with that display such that every few times we turn it on it doesn't display anything - no matter we'll fix that later. I want to try the motor now and powering the arduino from the 12V source.

That was also a motor test with a very simple piece of arduino code. The only things we need to test now are the really and the thermistors which we will do when the larger resistors show up. I don't know why the display isn't working today, no matter, we'll also figure that out some other time. I don't know how many things we can power from the arduino at once but here are the things that are being powered from it:

(1) the display
(2) the relay
(3) the two thermistors

Which honestly, should be completely fine. I don't know what's going on but hopefully we fix this display issue soon it seems to have a mind of its own.

The battery works!!! YAY!!!

#updates #omgrobots #filament_one

0 views0 comments
© copyright 2019 | aditya mehrotra