Go Down

Topic: sketch good / schematic doesn't work (Read 406 times) previous topic - next topic

imh747

Hi veryone,   :)

I need some help.
I'm new in programming.
How do you improve skills in Arduino.
Do you advise learning C++ before learning Arduino?

Here is a sketch that looks good. The compilation is great but, nothing happened in the schematic with SIMULIDE.

Thank you very much

-----
const int buttonAPin = 2;  // Enter
const int buttonBPin = 4;  // Menu
const int buttonCPin = 7; // Zoom in

const int ledAPin = A5;
const int ledBPin = A6;
const int ledCPin = A7;

// Variable will change:
int buttonAState = 0;
int buttonBState = 0;
int buttonCState = 0;

void setup() {
// Initialize the button pin as input:
  pinMode(2, INPUT);
  pinMode(4, INPUT);
  pinMode(7, INPUT);
// Initialize the LED pinas an output:
  pinMode(ledAPin, OUTPUT);
  pinMode(ledBPin, OUTPUT);
  pinMode(ledCPin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  buttonAState = digitalRead(buttonAPin);
  buttonBState = digitalRead(buttonBPin);
  buttonCState = digitalRead(buttonCPin);

  if (buttonAState == HIGH) {
    digitalWrite(ledAPin, HIGH);   
      } else {
        digitalWrite(ledAPin, LOW);
      }
  if (buttonBState == HIGH) {
        digitalWrite(ledAPin, HIGH);   
      } else {
        digitalWrite(ledAPin, LOW);
       }
  if (buttonCState == HIGH) {
        digitalWrite(ledAPin, HIGH);
      } else {
        digitalWrite(ledAPin, LOW);
      }
}



westfw

Quote
const int ledBPin = A6;
const int ledCPin = A7;
A6 and A7 are Analog Input Only.  They won't drive LEDs

MorganS

I can't see any power on the schematic. Doesn't it need power?

"The problem is in the code you didn't post."

wvmarle

No pull-ups on the buttons nor INPUT_PULLUP as pinMode. Doesn't bode well. Though it may be that the image is simply too low resolution to actually see them...
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

imh747

Hi there,

You didn't answer to my topic
Maybe you are very very busy.  :(
I can understand.

Could you please give me an answer to this:
is it possible for Arduino to send any data to
i.e. Notepad or any other program?

I'd like to use Arduino as a joystick emulator.

Hope to reed you soon.

Thank you  :)

TomGeorge

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Your diagram is  too small to really see your circuit.

What is your code supposed to do?
Where are the series current limit resistors for what I assume are supposed to be LEDs.

It seems some of your problem is with "SIMULIDE", how much experience have you had with this simulator.

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....

groundFungus


Quote
is it possible for Arduino to send any data to i.e. Notepad or any other program?
The only way for an Nano to communicate with a PC is through the serial port.  A Nano cannot, directly, write data to a Windows program.  You need a separate program on the PC to read the serial port and send the data to the Windows program.

imh747

Hi everyone,
Thank you for your rich responses.

Hi,
Welcome to the forum.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Your diagram is  too small to really see your circuit.

What is your code supposed to do?
Where are the series current limit resistors for what I assume are supposed to be LEDs.

It seems some of your problem is with "SIMULIDE", how much experience have you had with this simulator.

Thanks.. Tom.. :)
I read all the "how to use this forum"
Sorry if I make some mistakes.  :)

Is it possible to post the simu file?
I've change a little bit the code. You will find it down bellow.

What I'd like to do is to make each interrupter to switch on/off one LED accordingly.

At the end I'd like to replace the LED with a code send to a windows program.

Here is the code:
Code: [Select]

const int buttonAPin = 2;  // Enter
const int buttonBPin = 3;  // Menu
const int buttonCPin = 4; // Zoom in
const int buttonDPin = 5; //
const int buttonEPin = 6; //
const int buttonFPin = 7; //

const int ledAPin = 8;
const int ledBPin = 9;
const int ledCPin = 10;
const int ledDPin = 11;
const int ledEPin = 12;
const int ledFPin = 13;

// Variable will change:
int buttonAState = 0;
int buttonBState = 0;
int buttonCState = 0;
int buttonDState = 0;
int buttonEState = 0;
int buttonFState = 0;

void setup() {
// Initialize the button pin as input:
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);
// Initialize the LED pinas an output:
  pinMode(ledAPin, OUTPUT);
  pinMode(ledBPin, OUTPUT);
  pinMode(ledCPin, OUTPUT);
  pinMode(ledDPin, OUTPUT);
  pinMode(ledEPin, OUTPUT);
  pinMode(ledFPin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  buttonAState = digitalRead(buttonAPin);
  buttonBState = digitalRead(buttonBPin);
  buttonCState = digitalRead(buttonCPin);
  buttonDState = digitalRead(buttonDPin);
  buttonEState = digitalRead(buttonEPin);
  buttonFState = digitalRead(buttonFPin);

  if (buttonAState == HIGH) {
    digitalWrite(ledAPin, HIGH);   
      } else {
        digitalWrite(ledAPin, LOW);
      }
  if (buttonBState == HIGH) {
        digitalWrite(ledBPin, HIGH);   
      } else {
        digitalWrite(ledBPin, LOW);
       }
  if (buttonCState == HIGH) {
        digitalWrite(ledCPin, HIGH);
      } else {
        digitalWrite(ledCPin, LOW);
      }
  if (buttonDState == HIGH) {
        digitalWrite(ledDPin, HIGH);
      } else {
        digitalWrite(ledDPin, LOW);
      }
  if (buttonEState == HIGH) {
        digitalWrite(ledEPin, HIGH);
      } else {
        digitalWrite(ledEPin, LOW);
      }
  if (buttonFState == HIGH) {
        digitalWrite(ledFPin, HIGH);
      } else {
        digitalWrite(ledFPin, LOW);
      }
}



TomGeorge

Hi,
I know nothing about SIMULIDE, nor do I have the app.

Can you please tell us your electronics, programming, Arduino, hardware experience?

Unfortunately the image you posted is too small to read the main connections.

What are the diodes for that are in series with the buttons?
What do the buttons do when pressed, pull the digital input up to 5V down to gnd, in either case you do not have pullup or pulldown resistors for the digital inputs.

Tom... :)

Everything runs on smoke, let the smoke out, it stops running....

imh747

Hi Tom,
Thank you for your answer.
I get the SIMULIDE by SourceForge web site.
I have no experience at all, I'm learning.

Please see if this image is better for you:



al2 co3 3 compound name

What are the diodes for that are in series with the buttons?
What do the buttons do when pressed, pull the digital input up to 5V down to gnd, in either case you do not have pullup or pulldown resistors for the digital inputs.


Well, I'm going to learn more about pullup and pulldown resistors.

Thanks Tom
George

Go Up