Recent Posts

Pages: 1 [2] 3 4 ... 10
11
Device Hacking / Joystick controller USB interf...
Last post by leejones15 - Today at 04:03 am
Hi folks,
I have a Turnigy 5x controller that I would like to hook up to my PC so that I can use it with a flight simulator. 
I've tried out UnoJoy, but the main file uses analog for the thumbsticks, but mine returns PWM values.  I found one example that uses PWM, but it is for a controller than packages all the sticks into a single PWN output.  My controller sends individual signals for each axis and stick (so 4 outputs/inputs instead of one from the previous tutorial).
I've arduino experienced, but not very code saavy, so this is out of my own problem-solving capabilities.  If anyone has done this before, or can offer up a code that I can try, I would appreciate the help.

TIA

Code: [Select]

#include "UnoJoy.h"

bool FirstLoop;
dataForController_t controllerData;

#define PPM_Pin 3   // Pin of PPM Input. Must be 2 or 3
int ppm[16];        // array for storing up to 16 servo signals

void setup(){
  setupUnoJoy();
 
  FirstLoop = true;

  pinMode(PPM_Pin, INPUT);
  attachInterrupt(PPM_Pin - 2, read_ppm, CHANGE);

  TCCR1A = 0;  //reset timer1
  TCCR1B = 0;
  TCCR1B |= (1 << CS11);  //set timer1 to increment every 0,5 us
}

void loop(){
  if(FirstLoop == true) {
    controllerData = getControllerData();
    FirstLoop = false;
  }

  controllerData.leftStickX = map(ppm[0], 990, 2010, 0, 255);
  controllerData.leftStickY = map(ppm[1], 990, 2010, 0, 255);
  controllerData.rightStickX = map(ppm[2], 990, 2010, 0, 255);
  controllerData.rightStickY = map(ppm[3], 990, 2010, 0, 255);

  setControllerData(controllerData);

}

dataForController_t getControllerData(void){
  dataForController_t controllerData = getBlankDataForController();

  controllerData.triangleOn = 0;
  controllerData.circleOn = 0;
  controllerData.squareOn = 0;
  controllerData.crossOn = 0;
  controllerData.dpadUpOn = 0;
  controllerData.dpadDownOn = 0;
  controllerData.dpadLeftOn = 0;
  controllerData.dpadRightOn = 0;
  controllerData.l1On = 0;
  controllerData.r1On = 0;
  controllerData.selectOn = 0;
  controllerData.startOn = 0;
  controllerData.homeOn = 0;

  controllerData.leftStickX = 0;
  controllerData.leftStickY = 0;
  controllerData.rightStickX = 0;
  controllerData.rightStickY = 0;
 
  return controllerData;
}

void read_ppm(){  //leave this alone
  static unsigned int pulse;
  static unsigned long counter;
  static byte channel;

  counter = TCNT1;
  TCNT1 = 0;

  if(counter < 1020){  //must be a pulse if less than 510us
    pulse = counter;
  }
  else if(counter > 3820){  //sync pulses over 1910us
    channel = 0;
  }
  else{  //servo values between 510us and 2420us will end up here
    ppm[channel] = (counter + pulse)/2;
    channel++;
  }
}
12
I'm trying to control a servo based on the analog values from a sound sensor. The idea is that when the sound sensor senses a spike in volume (i.e. the analag values jump), then the servo will move to a position. The problem is that when the servo is energized the sensor values go crazy. I'm using an arduino nano with a Tower Pro SG90 micro servo. The servo is being powered by the arduino 5V pin. My guess is that when the servo draws power from the arduino the voltage to the sound sensor changes. I know this can be fixed by providing a seperate voltage source to the servo, however for my design I need the arduino to power both the servo and the sensor. Has anyone ran into an issue like this before? I'm thinking I can fix the issue by interrupting the analogread() from the sensor when the servo is called to run, but I'm not sure how to do this.

Thanks for any feedback.
13
Audio / Audio Output from SD
Last post by MSULudingtonPump - Today at 04:02 am
Hey guys. I'm not very experienced with audio, and most of the posts in this category make no sense to me, so I thought I'd just make my own post.

The Goal: I want to play an audio file from an SD card through two 4 Ohm 3 W speakers.

Background:
  • I already have an SD card breakout board and an SD card.
  • The SD card is wired up to my Arduino (Mega 2560), and the audio file is detected.
  • Needs to be sort of loud, so an amplifier is needed

I've been looking at the amplifier below, but am not sure how to send the data from the audio file to the board. There are three terminals for Left channel, Right channel, and ground; but what would I connect those to on the Arduino? Is this even possible? Any help is greatly appreciated!

Amplifier:
https://learn.adafruit.com/adafruit-20w-stereo-audio-amplifier-class-d-max9744?view=all
14
General Electronics / Re: RC project
Last post by Wawa - Today at 04:02 am
An L293 on a 12volt (max) motor supply would just be ok.
There are two of those chips on a v1 motor shield, if you want to go with a shield.
A v2 shield could squeeze a bit more speed  out of the batteries, but you want cheap.
Leo..
15
Hey aandrew7

This is something I quickly put together.
I've not tested it but I'm working on the assumption that the first example you posted did in fact work.
Read the description on the big comment at the top, and my massive disclaimer  ;)

The comments should explain thing, but try also to work through the logic of it all.

Cheers...

Code: [Select]

  /**************************************************************************************************/
  /*                                                                                                */
  /* This code aims to do two things                                                                */
  /*                                                                                                */
  /* 1. Read a potentiometer and use the output to drive a stepper motor at speed                   */
  /*    The code for this was taken from an example from the web                                    */
  /* 2. Check on two limit switches and determine if one has been activated. If so,                 */
  /*    Reverse the direction of motion                                                             */
  /*                                                                                                */
  /* The design of part 2 is as follows:                                                            */
  /*                                                                                                */
  /* set up two pins in INPUT_PULLUP mode.                                                          */
  /* assign 2 logical variables, toggle and recently_reversed.                                      */
  /* assign one integer variable, direction, which will be set to 1 or -1                           */
  /* toggle will be set to true if either one of the pins gets set LOW                              */
  /* recently_reversed will be set to true if direction gets flipped from 1 to -1 or vice versa     */
  /*                                                                                                */
  /* If a limit swich is hit, we set toggle. If recently_reversed is false, we flip direction       */
  /* If a limit swich is hit, we set toggle. If recently_reversed is true, we do nothing            */
  /* (this will stop us from constantly flipping direction while the limit switch is active         */
  /* If no limit switch is hit , toggle is set to false                                             */
  /* If limit switch is false, we set recently_reversed to false                                    */
  /* When it comes time to move the motor, we multiply the steps by direction to give               */
  /* a positive or negative value for rotation                                                      */
  /*                                                                                                */
  /* The limit switches to be used should be the lever type with three pins                         */
  /* Pin COM on the limit switch should be connected to ground                                      */
  /* Pin NO on the limit switch  should be connected to the input pin on the Arduino.               */
  /* As there is no external voltage and INPUT_PULLUP is used, no resistor will be necessary        */
  /*                                                                                                */
  /* This is for example only. It will give an idea of how to read a digital pin                    */
  /* and how to use those results in a process.                                                     */
  /* This IS NOT the best or most efficient method of controlling a stepper motor and its direction */
  /* This IS NOT the best or most efficient method of utilising limit switches                      */
  /* THIS IS A VERY QUICK AND DIRTY EXAMPLE ONLY                                                    */
  /*                                                                                                */
  /* As I have no hardware to test, only logical debugging has been done. This could should work    */
  /* but is provided AS IS with no warranties etc                                                   */
  /*                                                                                                */
  /**************************************************************************************************/
 
#include <Stepper.h>

const int stepsPerRevolution = 200;   // change this to fit the number of steps per revolution
                                      // for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

int stepCount = 0;  // number of steps the motor has taken

#define Limit01 2 // Pin 2 connected to Limit switch out
#define Limit02 3 // Pin 3 connected to Limit switch out

#define FORWARDS 1    // will be used to determine direction of travel
#define BACKWARDS -1

int direction = FORWARDS;
bool toggle = false;  // toggle variable to detect if reversing is required
bool recently_reversed = false; // flag to ensure that we clear limit switches before reversing again

void setup() {
 pinMode (Limit01, INPUT_PULLUP);  // limit switch is active when this pin is set LOW
 pinMode (Limit02, INPUT_PULLUP);  // limit switch is active when this pin is set LOW
}

void loop() {
 
   

  // read limit switches. If either is set LOW, toggle will be true
  toggle = (!digitalRead(Limit01) | !digitalRead(Limit02));
  if (toggle && !recently_reversed) {
    // one of the limit switches was hit, reverse direction
    if (direction == FORWARDS)
      direction = BACKWARDS;
    else
      direction = FORWARDS;
    recently_reversed = true;
  }
  if (!toggle && recently_reversed) // have we cleared the limit switch after reversing?
    recently_reversed = false;
   
  // read the sensor value:
  int sensorReading = analogRead(A0);
  // map it to a range from 0 to 100:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
  // set the motor speed:
  if (motorSpeed > 0) {
    myStepper.setSpeed(motorSpeed);
    // step 1/100 of a revolution:
    myStepper.step(direction * (stepsPerRevolution / 100));
  }
}

16
Hello, I've got this project with me about PIR motion sensor and led light on Arduino. Can you please help me with the code that I need. I want to count the number of led blinks (which is also the no. of motion detected) within time interval (2 hours for example) and send me alarm message/buzzer if no motion/blink happened within that period.
17
MKRVIDOR4000 / Re: MKRVidor4000 - Using DC mo...
Last post by RyanC6 - Today at 03:52 am
That helps heaps, thank you!
18
Proyectos / Re: Diseño Controlador Acuari...
Last post by car127 - Today at 03:51 am
    El termino lo tome de la misma pagina " En el lenguaje común, al orto se le denomina amanecer, alba o aurora. En ocasiones se diferencia la aurora, que sería el primer resplandor del cielo, del amanecer, que correspondería a la salida del sol"
mañana veré bien lo de las fases del día justo es este Alba, Luna y Ocaso me estan dando problemas sino dejare los basicos Noche, Amanecer, Sol, Atardecer y Luna que son los mas significativos

Sigue igual, para que vuelva el signo se tiene que mover (girar) el encoder avanzar y luego retroceder y aparece



   Como tu has dicho no es poca cosa, es mucho lo que se a logrado y de una manera sencilla  ""entre comillas para que la mayoría pueda entenderlo y realizarlo y por ultimo tener una base de donde partir y molestar menos en el foro como me paso ami barias veces no debo negar que recibí ayuda si, pero varias me mandaron a estudiar cosas que para mi eran chino.
   Conforme, muy conforme con tu paciencia y con lo que se ha realizado
19
General Electronics / Re: RC project
Last post by MCRobot92 - Today at 03:51 am
So you already have the motor(s).
Post a link to the datasheet of the motor that includes stall current.

Adafruit has replaced the L293D with the TB6612 on their v2 motorshield.
Leo..
https://puu.sh/Byouq/88dad7747a.png

Is what I'm leaning towards. Plastic case, metal geared economy motors, advertised at 100 RPM, unless I should go lower or higher, I'm completely open to input... The object would be a lightweight (probably less than 2 pounds).
20
I fear that it ends up with your electronic (soldering) skills. Eventually you can find a kit for a LED matrix that fits your needs. Combining multiple grids is not a big problem.

A simplel solution were LED strips, with one LED per storage position. Or with a LED or two skipped between compartments...
Pages: 1 [2] 3 4 ... 10