Show Posts
Pages: 1 ... 141 142 [143] 144 145 ... 312
2131  International / Deutsch / Re: Hilfe beim Speichern und Abrufen von PWM Werten gesucht on: March 07, 2013, 12:12:48 pm
Als erstes habe ich mal Deinen Code massiv verkürzt, indem ich die möglichen Werte in einem Array abspeichere. Damit dies nicht mehr RAM benötigt (davon haben wir nicht so viel), wird das im Flash gespeichert, was leider etwas komplizierteren Code beim Auslesen verlangt.

Bitte frage nach, wenn Du etwas nicht verstehst.

Code:
const int potiMin = 0;                                // Poti Minimum
const int potiorMax = 1023;                       // Poti Maximum
uint8_t ledPin1 = 9;                                  // LED 1 an digital pin 9
uint8_t ledPin2 = 10;                                // LED 2 an digital pin 10

PROGMEM uint8_t outvalue1[] = {0, ..., 255}; // Liste der möglichen Werte für LED1
PROGMEM uint8_t outvalue2[] = {50, ..., 182}; // Liste der möglichen Werte für LED2
 
void setup()
{
  Serial.begin(9600);                                // serielle Schnittstelle initialisieren
}

void loop()
{
  int poti = analogRead(A0);                   // Poti auslesen
  int range = map(poti, 0, 1023, 0, 63);   // Poti Gesamtbereich in 64 Bereiche unterteilen
                                                                 
  Serial.print("B ");                    // "B X" für Bereich X anzeigen
  Serial.println(range);
  analogWrite(ledPin1, pgm_read_byte(outvalue1+range));                // PWM Wert aus Flash an LED 1
  analogWrite(ledPin2, pgm_read_byte(outvalue2+range));               // PWM Wert aus Flash an LED 2
  delay(10);                               
}

Jetzt geht es noch darum, die Taster auszulesen. Hast Du dazu auch schon Code geschrieben? Versuche das mal und teste es an Deiner Schaltung aus.
2132  Using Arduino / Project Guidance / Re: Pulse limiter? on: March 07, 2013, 09:21:41 am
All global variables changed in an interrupt handler have to be declared "volatile". Otherwise the compiler may do wrong optimizations.
An int isn't big enough to hold the micros value, it has to be an unsigned long or clearer: uint32_t.

Code:
volatile uint32_t currentMicros, previousMicros, lowTime;
2133  Using Arduino / Project Guidance / Re: Pulse limiter? on: March 07, 2013, 08:13:16 am
Quote
I think the high voltage doesn't matter in the other system, just the ground signal.

Does that mean if the Arduino pulls the signal to 5V the other device won't be harmed? Do you have a datasheet for that device to check that?

Quote
Copying of the input should be possible with "change" interrupt, but how about "recording" the length of HIGH and LOW from the input,

Why do you need to record the length of a HIGH (or LOW) if you just need the frequency? Install an interrupt handler for RISING edges on pin 2 or 3 and record the time between the two rising edges, the reciprocal value is the frequency.
The output can be a PWM pin (for higher frequencies) or a simple digital output you control from the main loop.
2134  Using Arduino / Project Guidance / Re: Arduino Uno or Arduino Mega on: March 07, 2013, 07:58:12 am
Quote
Thank you, so it is possible to connect 4 modules to the Arduino Uno, but can only receive from one Serial input at a time (might be able to multiplex this?). Would this cause things like missing data?

Yes, it is possible to connect them but you would have to control, when they send something to the UNO. If you cannot control that (like with the RFID modules you mentioned) you have a very high potential of data loss.

Quote
The Mega2560 gives the possibility to receive from 4 Serials in parallel? I read that the Serial ports 0 and 1 are connected to the Serial over USB, wouldn't this cause all data that is sent to the module connected to 0 and 1 to be sent over USB to my PC too?

Yes, everything you send to the module on serial port 0 (pins 0 and 1) is sent to the PC too if it's connected by USB. If you need that connection to the PC (over the USB) and can connect one of the modules by SoftwareSerial.

Quote
The last question that remains is if it is possible to power the 4 modules with one arduino

Yes, the four modules consume a 280mA max. which should be no problem if they are the only devices connected to the Arduino.
2135  International / Deutsch / Re: SainSmart vs. Arduino on: March 07, 2013, 07:48:56 am
Quote
Die SainSmart Boards und Shields basieren auf den vom Arduino-Projekt veröffentlichten Open-Hardware-Designs der Boards und Shields und sind von der Programmierung her kompatibel zu den von Arduino selbst vertriebenen Boards und Shields.

Das stimmt zwar, aber die Sainsmart-Komponenten fallen hier im Forum immer wieder mal auf durch schlechte Verarbeitung. So sind z.B. die Ethernet Shields relativ häufig von den zu kurzen ICSP-Headern betroffen, welche Wackelkontakte auslösen, die sich in sporadischem Nicht-Funktionieren äussern können. Kurz gesagt: dem unbedarften Anfänger nicht zu empfehlen, vor allem da die Original-Teile nicht viel mehr kosten und die Kostenersparnis den potentiellen Ärger nicht wert ist.
2136  International / Deutsch / Re: Hilfe beim Speichern und Abrufen von PWM Werten gesucht on: March 07, 2013, 06:23:11 am
Quote
Im Prinzip verstehe ich das, ich stehe aber doch noch zu sehr am Anfang, um es auch umsetzen zu können. Ich wäre sehr dankbar, wenn mir jemand genauer sagen würde, wie ich meine Idee konkret angehen soll bzw. wo ich mich schlau machen kann.

Was an Uwe's Vorgehen verstehst Du denn nicht? Ich finde es sehr anschaulich erklärt. Erwarte bitte nicht, dass wir Dir hier fertigen Code vorsetzen, zuerst musst Du mal Eigeninitiative zeigen. Versuche mal, Uwe's Beschreibung in Code umzusetzen. Wenn das nicht funktioniert, poste den Code, den Du hast und wir versuchen Dir zu erklären, was Du noch verbessern musst.
2137  Using Arduino / Project Guidance / Re: Arduino Uno or Arduino Mega on: March 07, 2013, 05:22:30 am
At a baud rate of 9600 it's often convenient to use SoftwareSerial, a software emulation of the hardware serial found on pins 0 and 1, to communicate to not so picky devices. But you can have only one instance of SoftwareSerial receiving at a time so if you want to connect four modules you must go for the Mega2560 with it's four hardware (USART) serial interfaces.
2138  Using Arduino / Project Guidance / Re: arduino as bluetooth keyboard - no scancodes sent? on: March 07, 2013, 05:17:29 am
Quote
I assumed that this bluetooth module, which is in HID mode, would behave and be seen as a keyboard?

How do you know it's in HID mode? Most of these devices default to the Serial Profile. Just because you once switched it to HID mode doesn't mean it stays there (I don't know that particular module so I might be wrong here).

Quote
I guess my basic thought was that sending an ascii A was the same as pressing the A button on a keyboard, since my bluetooth module is acting as a Human Interface Device (the module is in keyboard mode by default in its firmware).  Am I wrong in thinking that?

Yes. The scancode for an 'a' (without holding shift) on a US keyboard is 0x04, far away from it's ASCII code 0x41 which you sent. It's possible that your BT module makes some conversion but all these conversions are specific to a selected keyboard layout then. Look that up in your module's documentation or at least provide a link to it.
2139  Using Arduino / Networking, Protocols, and Devices / Re: TLC5940 and Ethernet Shield using SPI on: March 07, 2013, 05:05:08 am
I explicitly told you that you must not connect pin 10 to XERR, I hope your "not this" means you haven't made that connection. Why is it still in the list?

In your list you still have two pins listed twice so my belief in that being the actual wiring is a bit lowered.

On which pin is SS located on your TLC?

Have you tried this configuration without the Ethernet shield? Does it work? What code are you using for your tests?
2140  Using Arduino / Project Guidance / Re: arduino as bluetooth keyboard - no scancodes sent? on: March 06, 2013, 05:52:49 pm
Edit your post and insert code tags!
2141  Using Arduino / Programming Questions / Re: serial communication on: March 06, 2013, 05:51:59 pm
Quote
can i use arduino uno serial without usb wire attach?

Yes.

Quote
means i use rf with two pins tx and ground in which pin is attach plz guide properly....

No, you have to guide us of what you're trying to do. What does RF mean? Provide a link to the device you want to connect to your Arduino. Also, provide a description of your project so we know what you're trying to achieve.
2142  Using Arduino / Project Guidance / Re: analog connection between 2 Arduinos -not i2c or serial on: March 06, 2013, 05:46:32 pm
Quote
and for discussion sake here is the other stuff im doing..not directly on the arduino its a chipkit32 and faster so I know as far as i can see that firmata wont work on it but simple serial stuff should..and im testing the serial for arduino anyway

You're mixing a lot of stuff, chipKit32 with Arduino, PWM with an analog signal, serial with I2C and firmata with OSC.

In your sketch you're using some analog value to control two stepper motors. If that's running on the chipKit32, what's the job of the Arduino? Do you have an overall description of your project to give us a picture of what you're trying to achieve?
2143  Using Arduino / Networking, Protocols, and Devices / Re: TLC5940 and Ethernet Shield using SPI on: March 06, 2013, 05:35:12 pm
A bit (unusable without modification) code to illustrate what I mean:

Code:
byte saved_spcr = 0;
byte saved_spsr = 0;
byte tlc_spcr = 0;
byte tlc_spsr = 0;

void setup() {
  Ethernet.begin(...);
  saved_spcr = SPCR;
  saved_spsr = SPSR;
  Tlc.init(...);
  tlc_spcr = SPCR;
  tlc_spsr = SPSR;
}

void loop() {
  SPCR = saved_spcr;
  SPSR = saved_spsr;
  Ethernet.anyCall(...);
  SPCR = tlc_spcr;
  SPSR = tlc_spsr;
  Tlc.anyCall(...);
}
2144  Using Arduino / Project Guidance / Re: arduino as bluetooth keyboard - no scancodes sent? on: March 06, 2013, 05:22:15 pm
Show us your code, maybe I understand your problem better then.
2145  Using Arduino / Project Guidance / Re: Pulse limiter? on: March 06, 2013, 05:12:00 pm
Quote
Interrupts could work, but I haven't got it working yet...

Where's your code, maybe we could help?

Quote
but I think Arduino cannot read it as HIGH, because it's under 1v or so...

Where is that signal originating from? Is it open drain? Is it possible to use a simple pull-up? Otherwise you need a MOSFET/Transistor to push it over 3V for the Arduino to recognize.

Quote
The pulse is about 25 - 250hz, but the duty cycle is about 2%.

That's not really a problem for the Arduino, it's more than fast enough for that.
Pages: 1 ... 141 142 [143] 144 145 ... 312