Recent Posts

Pages: [1] 2 3 ... 10
1
Code: [Select]

static bool dist_reach = false;
if(dist <5) {
  delay(1000);
  Serial.println("Checking Condition again");
  delay(10000);
  if(!dist_reach)
  {
    if(dist<5){
      Serial.println("sent notifcation1 to Telegram");     
      sendTelegramMessage();
      delay(bulk_messages_mtbs);
      Bot_lasttime = 0;
      dist_reach = true;
    }
  }
}
else if (dist >5) {
  if(dist_reach) {
    Serial.println("sent notifcation2 to Telegram");
    sendTelegramMessage2();
    delay(bulk_messages_mtbs);
    Bot_lasttime = 0;
  dist_reach = false;
  }
}




When it dist <5 it will check condition first then  sending TelegramMessage. But when during it  checking the condition i take off my hand the dist >5 it still sending the message.The condition checking system is not working.Any good suggestion ?
2
Microcontrollers / Wemos D1 Mini + BJT Unstable
Last post by zouje - Today at 03:12 am
Hi,

I am using a Wemos D1 Mini (Cheap clone) to control a 5V Songle relay. I have pin D4 set as an output and it is connected to the Base of a 2N3903 NPN BJT, through a 1KOhm resistor. The Emitter of the BJT is connected to ground, and the Collector is connected to +5V through a Songle relay coil (I measured 70Ohms for the coil). I also have a flyback diode across the relay coil.

When I RESET the Wemos board, even without commanding the D4 output, the D4 pin, as well as the 3.3V pin oscillate between 0 and 3.3V. This happens also if I keep the Collector unconnected to anything.

Does anyone have an idea about what the problem might be? I did some tests on the side, and with this setup, the BJT should consume about 2.5mA at the base (3.3V through 1KOhm resistor to the base). So even though I am using a cheap Wemos with a crappy 3.3V regulator, 2.5mA *should be* low enough not to cause any trouble.

Any help would be appreciated!

zouje.
3
What do you mean when you say "trying to load" that?

Trying to compile a sketch with that line? Trying to upload a sketch with that line? To what board? What makes you say there's a problem? (If you get an error message, post it, FFS! whenever you ask for help with any problem where an error message is shown (not just arduino, anything) always post the full text of any and all error messages. Just because you don't know what the error means doesn't mean the people you're asking won't)
4
Project Guidance / Re: I need help, please
Last post by Blackfin - Today at 03:04 am
The forum is called "Project Guidance."

As guidance, I suggest you do as others have suggested and study the Arduino platform you've been given.

Learn the basics of
- reading switches
- writing to an LCD
- interfacing to a sensor like the HR-SC04
- driving a buzzer

You can learn the bits and pieces individually and then put them together into a functional project.
5
Nederlands / Re: Arduino nano werkt niet me...
Last post by sterretje - Today at 03:04 am
Quote
Kan onderstaande code de bootloader "vernield" hebben of zo iets?
Alleen als je upload via ICSP. Maar dan zou je op dezelfde manier blink wel weer moeten kunnen laden; je zult wel de kaart lezer moeten afkoppelen in dat geval.

Ik heb geen kaart lezer, maar je scenario nagespeeld met een clone Nano en geen probleem ondervonden bij gebruik van USB.
6
General Electronics / Re: Using a 4x4 matrix keypad
Last post by DrAzzy - Today at 03:03 am
"sod all" seems to have been a point of confusion which was never explained. It's a phrase that has nothing (or should I say "sod all") to do with electronics: it's UK slang for "nothing" (and almost never used outside of the UK)

7
With posts spanning days, it is always best to assume the code has changed, especially when photos of the application do not match the source.

The program failure to retest a cable is due to variables not being re-initialized. The while loop is totally unnecessary. Here is a modified version that:

1) Properly re-initializes the required variables
2) Eliminates the while loop
3) Eliminates the use of the String class
4) Prepares the program for future expansion with the number of pins tested. This was more to remove the "magic number" "4" in every loop and array size declaration.

Code: [Select]

//Circuit tester sketch for Arduino Mega (Uno)
//(c) Samuel Silva
// Many thanks to Tony since this project contains 95% of its code
//GPLv3

//LCD
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR    0x27  // Define I2C Address where the PCF8574A is
// Address can be changed by soldering A0, A1, or A2
// Default is 0x27

// map the pin configuration of LCD backpack for the LiquidCristal class
#define BACKLIGHT_PIN 3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

LiquidCrystal_I2C lcd(I2C_ADDR,
                      En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin,
                      BACKLIGHT_PIN, POSITIVE);
//pins

#define sizeTest 4

int endA[sizeTest] = {4, 5, 6, 7}; //pins end A
int endB[sizeTest] = {8, 9, 10, 11}; //pins endB
int pSwitch = A0;
int pEncA = A1;
int pEncB = A2;


//results
int result[sizeTest];
int test[sizeTest];
int counter[sizeTest];
bool fail;

void setup() {

  Serial.begin(115200); //serial used for debugging only
  lcd.begin(20, 4);

  //setup pins
  for (int i = 0; i < sizeTest; i++) {
    pinMode(endA[i], OUTPUT);//set output pins (end A)
    pinMode(endB[i], INPUT_PULLUP);//set input pins (end B)
  }
  pinMode(pSwitch, INPUT_PULLUP);
  lcd.clear();
  lcd.print("Cable Tester 4 Pinos");
  lcd.setCursor(0, 1);
  lcd.print("Press Enc p/ Inicio");
}

void loop() {
  //run the test
  if (!digitalRead(pSwitch)) {
    runTest_4x1();
    delay(200);
  }
}

void runTest_4x1() {

  // add space for null terminator
  char s[sizeTest+1] = "0000";

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Testando: 4 pinos");
  lcd.setCursor(0, 1);

  // re-initialize reqired variables
  fail = false;
  for (int i = 0; i < sizeTest; i++){
    result[i] = -1;
    test[i] = -1;
    counter[i] = -1;
  }

  for (int i = 0; i < sizeTest; i++) {
    counter[i] = 0;
    for (int j = 0; j < 4; j++) {
      digitalWrite(endA[i], LOW); //set all outputs to LOW
    }
    for (int j = 0; j < sizeTest; j++) { //check for crossed / open circuits vs closed, good, circuits
      digitalWrite(endA[j], HIGH); //scan across the inputs in turn
      test[i] = digitalRead(endB[i]); //read the output
      if (test[i] == 1 && j != i) { //crossed or open circuit
        counter[i]++;
        result[i] = 8 + j; //alterei de 8 para 2 e não deu
      }
      else if (test[i] == 1 && j == i && result[i] < 8 ) { //Good, closed circuit
        result[i] = 0;
      }
      digitalWrite(endA[j], LOW);
      //debugging
      /*
        Serial.print("test1 input core  ");
        Serial.print(i);
        Serial.print(" with output core  ");
        Serial.print(j);
        Serial.print(" test =");
        Serial.print(test[i]);
        Serial.print(" counter =");
        Serial.println(counter[i]);
      */
    }
    Serial.print("Core ");
    Serial.print(i);
    Serial.print(" result = ");
    if (result[i] == 0) {
      Serial.println(" 1");
      s[i] = '1';
    }
    else if (counter[i] == 3) {
      Serial.println(" O");
      s[i] = '0';
      fail = true;
    }
    else {
      Serial.println(" X");
      s[i] = 'X';
      fail = true;
    }
  }
  lcd.print(s);
  lcd.setCursor(0, 2);

  if (fail) {
    Serial.println("DEFEITO");
    lcd.print("DEFEITO");
  }
  else {
    Serial.println("CABO OK");
    lcd.print("CABO OK");
  }
  Serial.println();
  lcd.setCursor(0, 3);
  lcd.print("Press Enc P/ Inicio");
}
8
Hello again,

It's been a couple years since I last posted, back when I was making a touchscreen remote to control my home theater (a successful project, btw, thanks to all the hard work put into IRremote and the help of this community).

Now I'm back at it again, only this time I modified a SNES controller (aftermarket wireless version) to be my "universal" remote, and I'm almost at the finish line...meaning I have total control over my JVC projector and the same is mostly true with my Marantz receiver, except for just two buttons.

These two buttons are part of the SOUND MODE group of buttons, of which there are a total of four: MOVIE, MUSIC, GAME, and PURE.  For my purposes, we can ignore GAME and PURE as I only use the first two.  

The button names, except for PURE, are actually superficial in that you can map them to whichever decoding scheme you choose.  So for example, you can map MOVIE to "Dolby Digital" and map MUSIC to "Multi-channel Stereo"...or you can map both buttons to Dolby Digital or map to DTS, etc.  

The way you program this using the remote is very interesting, because I can't seem to make sense of it based on the dumps shown using IRrecvDumpV2.  Here's how it works from the user's perspective:

1.  If I press MOVIE, it opens the SOUND MODE menu, which lists out the various sound modes (Dolby Digital, DTS, Stereo, etc), and correctly shows "Dolby Digital" as the selected sound mode.  If I do nothing, the menu disappears, so if the sound mode was already set to Dolby Digital then the end result is no change, just a presentation of the current sound mode.

2.  If I then press MUSIC, it will again open the SOUND MODE menu and correctly show "Multi-channel Stereo" as the selected option (and of course it is actually changing the sound mode to Multi-channel Music if it wasn't already enabled).

3.  If I press either button to open the SOUND MODE menu, then press the same button again, repeatedly, the selected sound mode will cycle through the list, allowing you to re-map the button to a new sound mode / decoding scheme.  The next time I press that sound mode button, it will open the SOUND MODE menu and show the newly selected sound mode.

So as you would expect, pressing MOVIE switches to Dolby Digital and pressing Music goes to stereo.  It is a great design from a programming perspective because only one button is involved per sound mode you want to map to and it works intuitively so it's simple for the end-user.

But here's where it gets confusing...

When looking at the IR dump after pressing the MUSIC button, I see that it alternates between THE SAME two codes as it does for the MOVIE button!  Both buttons share the same two codes.  One is interpreted as a RC5 code and the other uses an unknown protocol.  If I press and hold the button, then a third code is repeated, but I don't think that matters for my purposes as I don't intend on depressing a sound mode button (and depending on whether RC5 or UNKNOWN was used last, either that third code will repeat or the same RC5 code will).

If what I'm seeing in the dumps represents the entire picture, then how does my receiver know to select Dolby Digital vs Multi-channel Stereo when it's getting the same code from the remote?  For example, using the Marantz remote, I can send my receiver the RC5 code by pressing the MUSIC button (let's assume that's the one it sent), point the remote away from the receiver and press the button again so that it sends the UNKNOWN code, then point the remote back at the receiver and press the MOVIE button knowing it will send the same RC5 code and yet the receiver shows the correct sound mode is selected in the SOUND MODE menu.  

The only way I can see this as being possible is if there is 2-way communication going on or if the mechanism I'm using to capture signals from the remote (Arduino Uno plus IRrecvDumpV2) isn't good enough to capture all the data and so I'm missing some other codes being sent.  No matter what I send to the receiver, whether it's just the RC5 code, just the UNKNOWN code, or some combination of the two, the receiver doesn't respond in any way.  So I'm stuck and hoping the smarter minds on this forum can help me once again!

Here are the two alternating codes that the remote sends (again this is for both the MUSIC and MOVIE buttons, and pressing one button and then pressing the other doesn't change the fact that the remote ALWAYS alternates between these two codes and never sends the same one twice in a row):

Code: [Select]

Encoding  : RC5
Code      : 30 (6 bits)
Timing[13]:
    + 900, - 850     + 900, - 850     + 900, - 850     +1750, - 850
    + 900, - 900     + 850, - 850     + 900
unsigned int  rawData[13] = {900,850, 900,850, 900,850, 1750,850, 900,900, 850,850, 900};  // RC5 30
unsigned int  data = 0x30;

Encoding  : UNKNOWN
Code      : C3064C42 (32 bits)
Timing[11]:
    + 900, - 850     +1800, -1700     +1800, - 850     + 900, - 850
    + 900, - 850     + 900
unsigned int  rawData[11] = {900,850, 1800,1700, 1800,850, 900,850, 900,850, 900};  // UNKNOWN C3064C42



I also attached a pic of the remote showing the SOUND MODE button group, in case it helps.  Here is the link to my receiver's manual: http://m.us.marantz.com/DocumentMaster/US/mz_SR7012_om_u_en_v00.pdf

Since my sketch works in every other regard I don't think there is a problem with my code per-se, however I'm including it as a way of contributing back in case someone else finds it to be useful.  It's running on a Teensy 2.0 and this is the controller: https://www.amazon.com/gp/product/B075WRBK7Y/ref=ox_sc_act_title_1?smid=ATVPDKIKX0DER&th=1

Thanks,
Tony


9
Project Guidance / Re: project: Sending SMS using...
Last post by CelineGoh - Today at 02:57 am
ok I tried to use the SMS example from the examples they have included, but when I run it, the serial monitor never gives me the "ready" signal. Does this mean that there are issues connecting to the mobile network? How do I know if my device is connected to the mobile network?
the example code:
Code: [Select]
/*
 SMS sender

 This sketch, for the Arduino GSM shield,sends an SMS message
 you enter in the serial monitor. Connect your Arduino with the
 GSM shield and SIM card, open the serial monitor, and wait for
 the "READY" message to appear in the monitor. Next, type a
 message to send and press "return". Make sure the serial
 monitor is set to send a newline when you press return.

 Circuit:
 * GSM shield
 * SIM card that can send SMS

 created 25 Feb 2012
 by Tom Igoe

 This example is in the public domain.

 http://www.arduino.cc/en/Tutorial/GSMExamplesSendSMS

 */

// Include the GSM library
#include <GSM.h>

#define PINNUMBER ""

// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;

void setup() {
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("SMS Messages Sender");

  // connection state
  boolean notConnected = true;

  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while (notConnected) {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
      notConnected = false;
    } else {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("GSM initialized");
}

void loop() {

  Serial.print("Enter a mobile number: ");
  char remoteNum[20];  // telephone number to send sms
  readSerial(remoteNum);
  Serial.println(remoteNum);

  // sms text
  Serial.print("Now, enter SMS content: ");
  char txtMsg[200];
  readSerial(txtMsg);
  Serial.println("SENDING");
  Serial.println();
  Serial.println("Message:");
  Serial.println(txtMsg);
10
Try removing the files 'SHA204SWI.h' and 'SHA204SWI.cpp' from the folder containing the rest of the SHA204 library.

EDIT:
Quit the Arduino IDE before removing the files, then restart it.
Pages: [1] 2 3 ... 10