Go Down

Topic: write from one board's pin to read of another's not working (Read 132 times) previous topic - next topic

heaversm

Feb 05, 2020, 11:15 pm Last Edit: Feb 05, 2020, 11:38 pm by heaversm Reason: add voltage meter reading
I have an Intel Tiny Tile boardThis board is based on the Intel Curie, and can be read in Arduino as an Arduino 101.

I'm using this board's accelerometer to register the bounce of someone on a trampoline. I have it set up to write HIGH to a digital pin when its direction changes from negative to positive. That sketch is below - and works well on its own - I've tested it with the serial monitor.

I now want this pin to connect to a pin on an Arduino Mega. I wired the Tiny Tile pin 13 to a protoboard, and joined that protoboard connection with another that wires to the ATMega PIN 8. I'm reading for a HIGH state on the ATMega Pin 8. That sketch is included below as well, with a diagram of the wiring.

When I run the Mega sketch, I don't ever get anything printed to the serial monitor. I'm not sure what I'm doing wrong. Does anyone have any ideas?

Both boards are grounded, and I've tried powering the TinyTile both from the Mega's 3.3V port, and from its own power supply (seems to be getting power - green light is on).

At someone's advice, I connected a multimeter to the mega's ground, and to a pin in the breadboard between the tinytile's output wire (from pin 13), and the mega's input wire (leading to mega pin 8) - and got no voltage when shaking the accelerometer.



TinyTile Sketch:
Code: [Select]


    #include "CurieIMU.h"
    
    float lastZ = 0;
    float curZ = 0;
    
    boolean isBounced = false;
    int bounceCount = 0;
    
    unsigned long time_now = 0;
    int bounceTime = 500;
    
    const int LEDPIN = 13;
    
    boolean doSerial = false;
    
    
    void setup() {
      if (doSerial) {
        Serial.begin(9600); // initialize Serial communication
        while (!Serial);    // wait for the serial port to open
    
        //initialize device
        Serial.println("Initializing IMU device...");
      }
    
      CurieIMU.begin();
    
      // Set the accelerometer range to 2G
      CurieIMU.setAccelerometerRange(2);
    
      pinMode(LEDPIN, OUTPUT);
      digitalWrite(LEDPIN,LOW);
    
    }
    
    void loop() {
      float ax, ay, az;   //scaled accelerometer values
    
      // read accelerometer measurements from device, scaled to the configured range
      CurieIMU.readAccelerometerScaled(ax, ay, az);
    
      // display tab-separated accelerometer x/y/z values
      lastZ = curZ;
      curZ = az;
    
      if (lastZ < 0 && curZ > 0 && !isBounced) {
        bounceCount++;
        time_now = millis();
        isBounced = true;
        //if (bounceCount % 2 == 0){
        if (doSerial) {
          Serial.println(az);
        }
        digitalWrite(LEDPIN, HIGH);
        //}
    
      } else {
        digitalWrite(LEDPIN, LOW);
      }
    
      if ((millis() > time_now + bounceTime) && isBounced) {
        isBounced = false;
        time_now = millis();
    
      }
    
    
    }



Mega Sketch:
Code: [Select]


    //LED PINS
    const int LEDPIN = 8;
    
    boolean doSerial = true;
    
    void setup() {
      if (doSerial){
        Serial.begin(9600);
        while (!Serial);    // wait for the serial port to open
        Serial.println("initialized");
      }
      
      pinMode(LEDPIN, INPUT);
    
    }
    
    void loop() {
      int ledVal = digitalRead(LEDPIN);
      
      if (ledVal == HIGH){
        if (doSerial){
          Serial.println("bounce");
        }
      }
    }




pylon

Measure the output of the curie pin. If it's below about 3.2V if it's put to HIGH, the Mega2560 won't be able to read the signal as HIGH. In that case put a transistor on the breadboard to convert the voltage to a higher level.

gilshultz

You have a sure fail circuit. 3.3V logic will not drive typical 5V logic reliably. Simply add a level translator and all should work just fine.  This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

Go Up