Recent Posts

Pages: [1] 2 3 ... 10
1
I've already done that before I came here for help.  I have basically put it in to as close to correct code as I know.  If someone could give me some direction to what I should use as far as "if then else"  or what,  that would be fantastic. That is where i' m stuck.  Does that make sense?
2
I used this servo knob on public domain, but replaced the pot with audio through optocoupler PC817 hooked to input A0 through 10K pullup resistor. works good but the servo moves at every particle of audio high or low volume. I wish some advice to move it only at peak of words..help please. video here
https://www.youtube.com/watch?v=k6TeBKtsZvs
here is the code i am using working good on Nano
Code: [Select]
/*
 Controlling a servo position using a potentiometer (variable resistor)
 by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

 modified on 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Knob
*/

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

int potpin = 0;  // analog pin used to connect the potentiometer replaced with audio in thru optocoupler
int val = 0;    // variable to read the value from the analog pin
int val2 = 0;
void setup() {
  pinMode(potpin, INPUT);
  pinMode(9, OUTPUT);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
Serial.begin(9600);
}

void loop() {
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  val2 = map(val, 0, 1020, 30, 150);     // scale it to use it with the servo (value between 0 and 180
  myservo.write(val2); // sets the servo position according to the scaled value
 Serial.println(val);
 Serial.println(val2);
  delay(70);                           //give servo enough time to get there
}
3
Deutsch / Re: Lichtschranken timer
Last post by gregorss - Today at 06:33 am
Hallo erst einmal bin Anfänger und habe mich in richtung arduino noch nicht Beschäftigt. Ausser zu googln.

Ich habe eine Projekt Ider und hoffe das die mit arduino nano umzusetzen ist.
Zu meiner Idee.

Eine Lichtschranke erfasst ein und aus. Sollte das ein oder das aus länger als 1 sekunde ( am besten einstellbar über poti) betätigt oder unbetätigt sein leuchtet eine Led auf. (Später soll ein Servo auslösen.)

Das ganze sollte sich dann so nach 5 sek. Resten.

Also ist das sozusagen eine überwachungs schaltung.
Hat jemand ideen ob das so geht. Vil. Ein tuturial ?

Mfg


Deine Idee ist grundsätzlich umsetzbar. Du solltest Dich allerdings zunächst mit ein paar Grundlagen beschäftigen - zum Beispiel damit, Deine Idee in Form eines Programmablaufplans zu formulieren.

Gruß

Gregor
4
Sensors / Re: Temperature Sensor
Last post by Svx - Today at 06:33 am
How is an USB port not stable?
5
Project Guidance / Re: RS232 to TTL converter for...
Last post by larryd - Today at 06:31 am
So adding the jumper to the DB09 toggles the ttl pin 4.
Excellent!

Arduino power off

Now connect:
Scale pin 5 to converter DB09 pin 5
Scale pin 2 to converter DB09 PIN 3

Arduino 5v and GND to power converter.

Converter TTL pin 4 to your software RX pin.

Arduino Power on.
Using sketch from my post #44 (change software serial RX TX to the pins you want).

What comes on the Arduino serial monitor?


6
Displays / Re: 3.0" TFT LCD Touch Screen
Last post by bernardst - Today at 06:29 am
Very good thread, it has helped me a lot, thank you.
7
Deutsch / Re: Welchem Arduino brauch ich...
Last post by gregorss - Today at 06:26 am
Ich bin grad noch ziemlich frisch in der Digitaltechnik und versuche gerade einen MIDI Controller zu basteln.
Als Frischling solltest Du meiner Meinung nach unbedingt mit einem Original (Arduino) anfangen und Dich erst mal durch die Grundlagen arbeiten. Erst wenn Du damit MIDI-Nachrichten erzeugen und verschicken kannst, hast Du vermutlich „genug drauf", um aufwändigere Vorhaben anzugehen.

Gruß

Gregor
8
Good.

On the new converter:
- nothing connected to the DB09 connector
- Arduino +5V and GND connected to the converter TTL pins.
- Now we will try to manually key the RS232 receive pin on the DB09 side to check if it goes through to the TTL side.


Place a wire from +5v to DB09 pin 3   (5v and GND still connected to ttl side)

Measure voltage:
DB09 pin 5 (GND) to ttl pin 4 (was 5v) , pin should now toggle from 5v to 0v when jumper is removed/installed.

Yes
DB09 pin 5 (GND) to ttl pin 4 (was 5v), Voltage is now 0v
9
Project Guidance / Re: Help getting USB foot peda...
Last post by eKay - Today at 06:24 am
Can someone help me on how I can make the key hold? It just keeps repeating when held down which cuts Push to talk





Code: [Select]
#include <TrinketKeyboard.h>  // Trinket keyboard library

const int PIN_SWITCH = 0;    // Trinket pin to connect to switch

void setup()
{
  // Set button pin as input with an internal pullup resistor
  // The button is active-low, they read LOW when they are not pressed
  pinMode(PIN_SWITCH, INPUT_PULLUP);

  TrinketKeyboard.begin();  // initialize keyboard library
}

void loop()
{
  TrinketKeyboard.poll();
  // the poll function must be called at least once every 10 ms
  // or the computer may think that the device
  // has stopped working, and give driver errors

  if (digitalRead(PIN_SWITCH) == LOW)  // If the foot switch grounds the pin
  {
    // Select what key to press when the switch is tripped
    //   Possible keys are defined in TrinketKeyboard.h
    // Selected keys are Print Screen with the shift key modifier
    TrinketKeyboard.pressKey(0, KEYCODE_F8);
    TrinketKeyboard.pressKey(0, 0);  // release key
    // If you want to send a string, replace the 2 calls above with the line below
    // TrinketKeyboard.print("Hello World!"); // use for string instead of char
  }
}
10
Español / Ayuda grabar 5 posiciones de s...
Last post by Omar_vartan - Today at 06:23 am
Hola buenas noches soy nuevo en esto, mi siguiente duda es la siguiente lo que quiero hacer es grabar 5 posiciones del servomotor y después de que haya terminado te grabarlas reproducirlas en secuencia y que por medio de leds me avise que posición se esta ejecutando

saludos

Code: [Select]
#include <Servo.h>
#include <EEPROM.h>
#define Max 1023         //Valor máximo del potenciómetro
#define Min 0     //Valor mínimo del potenciómetro
int Grabar = 2; //Pulsador conectado al pin digital 2
int Reproducir = 5; //Pulsador conectado al pin digital 5
int Resetear = 6; //Pulsador conectado al pin digital 6
int servoPin = 9; //Servomotor conectado al pin digital 9
int POT = A5; //Potenciómetro conectado al pin análogo 7
int ledPin = 13; //LED conectado al pin digital 13
int addr;
Servo myServo;

void setup() {
  Serial.begin(9600);
  pinMode(Grabar, INPUT);       digitalWrite(Grabar, HIGH);
  pinMode(Reproducir, INPUT);   digitalWrite(Reproducir, HIGH);
  pinMode(Resetear, INPUT);     digitalWrite(Resetear, HIGH);
  pinMode(ledPin, OUTPUT);
  pinMode(POT, INPUT);
  myServo.attach(servoPin);
}

void loop()
{
 
  if(digitalRead(Reproducir) == HIGH)
  {
    int valorPOT = analogRead(POT);
    int angulo = map(valorPOT,0,1023,0,180);
    myServo.write(angulo);
  }
 
  if(digitalRead(Resetear) == LOW)
  {                                                   
    Serial.println("Borrando EEPROM, espere...");
    for(addr=0; addr<=512; addr++){ EEPROM.write(addr, 255); }   
    addr = 0;
    Serial.println("EEPROM borrada");
  }   

  if (digitalRead(Grabar)==LOW)
  {     
    delay(100);
    grabaServo(servoPin, POT);
  }
 
  if (digitalRead(Reproducir)==LOW)
  {       
    delay(400);
    ejecutaServo(servoPin, Reproducir);
  }
}

//--------Ejecuta posiciones almacenadas en la memoria-------------
void ejecutaServo(int servoPin, int botonPin) {
  addr = 0;
  Serial.println("Activando Servo");
  myServo.attach(servoPin);
  while (digitalRead(botonPin))
  {   
    int dato = EEPROM.read(addr);
    Serial.print("Lee EE: "); Serial.print(dato);
    if (dato == 255) break;                       
    dato = map(dato, 0, 254, 0, 180);             
    Serial.print(" -> "); Serial.println(dato);
    myServo.write(dato);
    delay(1500);
    addr++;
    if (addr == 512) break;
  }
  Serial.println(" y termina");
  delay(300);
}

//--------------Almacena posiciones en la memoria----------------
  void grabaServo(int servoPin, int analogPin) {
  Serial.println("Grabando posicion");
  digitalWrite(ledPin, HIGH);
  int dato = analogRead(POT);
  Serial.print("Valor analogico: "); Serial.print(dato);
  if (dato < Min) dato = Min; if (dato > Max) dato = Max; 
  dato = map(dato, Min, Max, 0, 254);                     
  Serial.print(" -> "); Serial.println(dato);
  EEPROM.write(addr, dato);
  addr++;
  digitalWrite(ledPin, LOW);
  Serial.println("Grabada posicion");
  delay(300);
}
Pages: [1] 2 3 ... 10