Show Posts
Pages: 1 2 3 [4] 5 6 ... 361
46  Using Arduino / Programming Questions / Re: Virtual shift register lacks the first bit... on: August 05, 2014, 11:38:29 pm
E) None of the Arduino's have to read the S88 bus. The master only have to send out the data.

The master sends the data out on the bus but the Arduino doesn't read that?
Arduino just sends data to the master through wireless?

47  Using Arduino / Sensors / Cap sense through a cap. Static safe now? on: August 04, 2014, 11:49:09 pm
There's a simple touch sensor that's just a conductor on a pin, it can tell if you touch it.
But that's open to static.

I got it working with a jumper wire, especially squeezed on.

So I took a 1 uF radial cap and straightened the legs out sideways and stuck one leg in the pin 7 hole of an UNO.
About the same results so I paper-clipped a folded piece of foil to the free lead and it knows touch the foil very well but well through a plastic card.

My guess though is that the capacitor should protect the Arduino from static up to some point. But personal static only carries so much total kick.
100 MFD electrolytic cap gave smaller numbers is all. Maybe it can absorb more spark?

Quick and dirty concept test. Tested, works. I used pin 7 for the sensor. No reason.

// readCapacitivePin
//  Input: Arduino pin number
//  Output: A number, from 0 to 17 expressing
//  how much capacitance is on the pin
//  When you touch the pin, or whatever you have
//  attached to it, the number will get higher
// #include "pins_arduino.h" // Arduino pre-1.0 needs this

const byte sensePin = 7;

uint8_t readCapacitivePin( byte pinToMeasure )
  // Variables used to translate from Arduino to AVR pin naming
  volatile uint8_t* port;
  volatile uint8_t* ddr;
  volatile uint8_t* pin;
  // Here we translate the input pin number from
  //  Arduino pin number to the AVR PORT, PIN, DDR,
  //  and which bit of those registers we care about.
  byte bitmask;
  port = portOutputRegister(digitalPinToPort(pinToMeasure));
  ddr = portModeRegister(digitalPinToPort(pinToMeasure));
  bitmask = digitalPinToBitMask(pinToMeasure);
  pin = portInputRegister(digitalPinToPort(pinToMeasure));
  // Discharge the pin first by setting it low and output
  *port &= ~(bitmask);
  *ddr  |= bitmask;
  // Prevent the timer IRQ from disturbing our measurement
  // Make the pin an input with the internal pull-up on
  *ddr &= ~(bitmask);
  *port |= bitmask;

  // Now see how long the pin to get pulled up. This manual unrolling of the loop
  // decreases the number of hardware cycles between each read of the pin,
  // thus increasing sensitivity.
  uint8_t cycles = 17;
  if (*pin & bitmask) {
    cycles =  0;
  else if (*pin & bitmask) {
    cycles =  1;
  else if (*pin & bitmask) {
    cycles =  2;
  else if (*pin & bitmask) {
    cycles =  3;
  else if (*pin & bitmask) {
    cycles =  4;
  else if (*pin & bitmask) {
    cycles =  5;
  else if (*pin & bitmask) {
    cycles =  6;
  else if (*pin & bitmask) {
    cycles =  7;
  else if (*pin & bitmask) {
    cycles =  8;
  else if (*pin & bitmask) {
    cycles =  9;
  else if (*pin & bitmask) {
    cycles = 10;
  else if (*pin & bitmask) {
    cycles = 11;
  else if (*pin & bitmask) {
    cycles = 12;
  else if (*pin & bitmask) {
    cycles = 13;
  else if (*pin & bitmask) {
    cycles = 14;
  else if (*pin & bitmask) {
    cycles = 15;
  else if (*pin & bitmask) {
    cycles = 16;

  // End of timing-critical section

  // Discharge the pin again by setting it low and output
  //  It's important to leave the pins low if you want to
  //  be able to touch more than 1 sensor at a time - if
  //  the sensor is left pulled high, when you touch
  //  two sensors, your body will transfer the charge between
  //  sensors.
  *port &= ~(bitmask);
  *ddr  |= bitmask;

  return cycles;

void setup( )
  Serial.begin( 115200 );
  Serial.println( F( "\n\nStart sensing!\n" ));

void loop( )
  Serial.println( readCapacitivePin( sensePin ));
  delay( 100 );

48  Community / Bar Sport / Very interesting video on cap sensor design. on: August 04, 2014, 02:09:02 pm

He has a sense plate and a ground plate that are separated horizontally so the plate fields spread out.
Then he makes the ground plate much bigger than the sense plate, concentrating potential on the sense plate.

There is also this:
I am liking the lack of resistors, etc, in the second approach, the 1-wire cap sense.

I don't like bare metal touch because of static and accidents. Touch paper over metal is better but I want plastic sheet over the paper. The button labels print on the paper, the cover sheet wipes off.

49  Using Arduino / Project Guidance / Re: program to find rpm on: August 02, 2014, 06:38:23 pm
You could get more samples by counting slots or spokes in a wheel than by just one point per revolution.
A gear tooth counter reads metal going by without needing attached magnets.
The counter has a field that metal moving through interacts with and there's the signal.

Can you put a light, small wheel against the wheel being measured?

If you're okay with IR sensors, office store printed transparency sheet is IR transparent.
It's a lot easier and cheaper to print a wheel with 1024 timing holes and a hub than it is to cut one from metal..

50  Using Arduino / Programming Questions / Re: Arduino Program Stop Working after 1 sec on: August 01, 2014, 02:20:25 am
My question was and is about what you seem to think some of the code is doing.
I don't know how that affects the whole but one good wrong assumption usually makes major problems.

I saw that and stopped right there and asked a question that you haven't bothered to answer at all.
I don't have your hardware setup to be able to find the answers myself either.

How much of that did you write before testing the first time?
51  Using Arduino / Audio / Re: Arduino library for WTV020-SD-16P audio module on: August 01, 2014, 01:46:59 am
You might be safe to feed it to amplified speakers but it would need resistors to feed as Line In to an amp.
52  Using Arduino / Programming Questions / Re: How to read values over serial on: July 31, 2014, 05:56:44 pm
You get serial by checking Serial.available().

How would you get a button? That may be trickier than just checking a pin, depending on the button but still the principle is the same.

The important part is to not let doing one thing hold everything else up, which is called blocking code.

53  Using Arduino / Programming Questions / Re: Arduino Program Stop Working after 1 sec on: July 31, 2014, 04:03:18 pm
I thought for sure that a led has a minimum trigger voltage by color and a maximum voltage not much more.
Red led needs > 1V doesn't it?
54  Using Arduino / Programming Questions / Re: How to read values over serial on: July 31, 2014, 03:59:58 pm
If you map something to degrees and then degrees to servo value not degrees then you set up for 2 round offs.
55  Using Arduino / Programming Questions / Re: How to read values over serial on: July 31, 2014, 03:22:01 pm
The whole page of Nick's blog covers the whole subject.
The second part is state machine showing exactly what you want and it does not need atoi().

When digits are received, as they arrive an unsigned int is 'moved up' 1 digit then the new digit is added.
This is because text numbers arrive high-value to low-value order.
123 is 1x100 + 2x10 + 3. So you read the 2 then x10 and add the 1, then x10 and add the 3 all as they come.

void processIncomingByte (const byte c)
  if (isdigit (c))
    currentValue *= 10;
    currentValue += c - '0';
  }  // end of digit

    // The end of the number signals a state change
    handlePreviousState ();

    // set the new state, if we recognize it
    switch (c)
    case 'R':
      state = GOT_R;
    case 'S':
      state = GOT_S;
    case 'G':
      state = GOT_G;
      state = NONE;
    }  // end of switch on incoming byte
  } // end of not digit  

If all you do is grab the code, you won't learn half of the tutorial there.
if you learn it all, this kind of thing will not be a problem again.

56  Using Arduino / Programming Questions / Re: Arduino Program Stop Working after 1 sec on: July 31, 2014, 01:39:33 pm
the 4 LEDs are turned on for 500 ms using PMW for a value of 10mv.
the 4 LEDs are turned on for 500 ms using PMW for a value of 250mv.
the 4 LEDs are turned on for 500 ms using PMW for a value of 50mv.
the 4 LEDs are turned on for 500 ms using PMW for a value of 0mv.

Unless you have a circuit to turn PWM into analog, it doesn't work that way.
PWM is full VCC for value/256 time out of each duty cycle.
Default duty cycle is about (just over) 2 ms. PWM 127 should get just over 1 ms ON, 1 ms OFF at 5V pattern.
57  Using Arduino / Programming Questions / Re: How to read values over serial on: July 31, 2014, 01:28:04 pm
Simple letter + value code is exactly what Nick Gammon addresses with example in this tutorial blog:

58  Using Arduino / Programming Questions / Updated SMlib code on: July 30, 2014, 10:24:47 am
I've reached the 9500 char post limit.
GitHub doesn't like XP.
Verizon is taking my web space in 2 months.
I won't be posting updated code though the code is updated.
59  Using Arduino / Programming Questions / Re: Non linear list and sensor values (that are not Integers) on: July 30, 2014, 09:09:21 am
Yeah but still, if the temperature is used to directly determine something else (formula of temperature and constants) then table the something else and save needing those steps and constants as well.

IE, don't table factors if results or partial results are more useful.

PS I could go farther.
Suppose you have 2 factors and a number of constants used in a complex formula, what do you do?
You use a 2 dimensional table as Jiggy-Ninja did. The formula reduces to lookups and interpolation if any is needed.
60  Using Arduino / Programming Questions / Re: How to share code? on: July 30, 2014, 07:54:17 am
I saw your code from github. to make your code easy for beginner like us to use. you need to write simple examples using your code. still, if you think your code is great. write a book about it.

That takes a lot. The book is likely more effort than the code.
But if 2 or more were to collaborate successfully, a group project of shared skills might go easier or devolve into a mess and fights, it's hard to say.  smiley-eek-blue

Pages: 1 2 3 [4] 5 6 ... 361