Servo rotation and 315Mhz T/R help

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
jc27
 
Posts: 185
Joined: Sun Nov 24, 2013 5:05 am

Re: Servo rotation and 315Mhz T/R help

Post by jc27 »

I got the 2 replacement trinket pros yesterday. I just plugged them into my laptop and tried to upload code and the new ones do the same thing as the first 2. I plug them in and the red led just blinks until I unplug it.
Here is the error I get: avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)
I have the board setting at pro trinket 5v 16 Mhz (USB) and the programmer at USBtinyISP
I ordered 2 more trinket pros along with a USB cable this past weekend, so I should have them b the end of the week. I am hoping that the issue is the USB cables I am using (maybe they are power only and not power and communication).

User avatar
jc27
 
Posts: 185
Joined: Sun Nov 24, 2013 5:05 am

Re: Servo rotation and 315Mhz T/R help

Post by jc27 »

I'm using a new USB cable and it seems to have solved my problem. Sometimes though I have to close the IDE and open the security setting on my Mac and follow the instructions that are in the trinket pro tutorial. And when I upload code, in the bottom right corner of the IDE it says its connected to "Pro trinket 5v/16 Mhz USB on /dev/tty.bluetooth-incoming-port", shouldn't it be connected to a USB port and not a Bluetooth port? In the Serial Port option of the IDE, all the options say Bluetooth, nothing listed says USB. Is this a problem or do I not need to worry about it?

User avatar
jc27
 
Posts: 185
Joined: Sun Nov 24, 2013 5:05 am

Re: Servo rotation and 315Mhz T/R help

Post by jc27 »

OK, I am going to necro this thread to ask a couple of questions. I have a working sketch and it uses a rolling code transmitter/receiver to eliminate any interference and cross talk.
Now I would like some LEDs to work along with the servo. There are 3 LEDs total, and I would like them only to work once the servo is in the down (90 degree position). One LED will be on and the other two will alternately blink on and off (one being on the other off). I was reading the trinket articles and it seems like I will need to do the LED blinking using the "flash without delay" action. I tried to incorporate it into my working servo code and it doesn't seem to work. The one LED comes on like it should, but the other two do not flask and the servo stops rotating about half way through its motion for a split second then continues to the stopping point, but the two flashing LEDs do not flash (one comes on, one is off and they do not alternate or do anything else). I am guessing its because of the delay I have in the servo rotation section of the code, so I guess that will need to come out, but if so, how would I control the speed of the rotation?
Here is the code as it sits now:

Code: Select all

            #include <Servo.h>
            int button1 = 3;
            int press1 = 0;
            int button2 = 4;
            int press2 = 0;
            Servo servo1;
            int redLed1 = 9;
            int ledState1 = LOW;
            unsigned long previousMillis1 = 0;
            long OnTime1 = 250;
            long OffTime1 = 750;
            int redLed2 = 10;
            int ledState2 = LOW;
            unsigned long previousMillis2 = 0;
            long OnTime2 = 330;
            long OffTime2 = 430;
            int perspexLed = 12;
            int pos = 48;
            bool minimum = true;
            bool maximum = false;

            void setup()
            {
              pinMode (redLed1, OUTPUT);
              pinMode (redLed2, OUTPUT);
              pinMode (perspexLed, OUTPUT);
              pinMode (button1, INPUT);
              pinMode (button2, INPUT);
              servo1.attach (6);
              servo1.write (48);
            }
            void loop()
            {
              unsigned long currentMillis = millis();
              
              if ((digitalRead(button1) == HIGH) && minimum)
              {
                for (int i = 0; i < 81; i++)
                {
                  pos ++;
                  servo1.write(pos);
                  delay (25);
                  //space for keeping track of new code
                   if((ledState1 == HIGH) && (currentMillis - previousMillis1 >= OnTime1))
                      {
                        ledState1 = LOW;  // Turn it off
                        previousMillis1 = currentMillis;  // Remember the time
                        digitalWrite(redLed1, ledState1);  // Update the actual LED
                      }
                      else if ((ledState1 == LOW) && (currentMillis - previousMillis1 >= OffTime1))
                      {
                        ledState1 = HIGH;  // turn it on
                        previousMillis1 = currentMillis;   // Remember the time
                        digitalWrite(redLed1, ledState1);	  // Update the actual LED
                      }
                      
                      if((ledState2 == HIGH) && (currentMillis - previousMillis2 >= OnTime2))
                      {
                        ledState2 = LOW;  // Turn it off
                        previousMillis2 = currentMillis;  // Remember the time
                        digitalWrite(redLed2, ledState2);  // Update the actual LED
                      }
                      else if ((ledState2 == LOW) && (currentMillis - previousMillis2 >= OffTime2))
                      {
                        ledState2 = HIGH;  // turn it on
                        previousMillis2 = currentMillis;   // Remember the time
                        digitalWrite(redLed2, ledState2);	  // Update the actual LED
                      }
                 
                }
                minimum = false;
                maximum = true;
              }
              if ((digitalRead(button2)) == HIGH && maximum)
              {
                for (int i = 81; i > 0; i--)
                {
                  pos --;
                  servo1.write(pos);
                  delay (20);
                  digitalWrite (redLed1, LOW);
                  digitalWrite (redLed2, LOW);
                  digitalWrite (perspexLed, LOW);
                }
                minimum = true;
                maximum = false;
              }
            }

User avatar
jc27
 
Posts: 185
Joined: Sun Nov 24, 2013 5:05 am

Re: Servo rotation and 315Mhz T/R help

Post by jc27 »

Hopefully I can get some pointers on this, if not I can start a new thread.

User avatar
adafruit_support_bill
 
Posts: 88097
Joined: Sat Feb 07, 2009 10:11 am

Re: Servo rotation and 315Mhz T/R help

Post by adafruit_support_bill »

Please start a new thread with the relevant information. This one is 3 years and 13 pages old.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”