Go Down

Topic: non-class type error (Read 520 times) previous topic - next topic

N314

(unfinished) sketch:
Quote

#include <seg.h>

Seg seg();

void setup()
{
}

void loop()
{
  digitalWrite(2, HIGH);
  seg.one();
  digitalWrite(2, LOW);
  delay(2);
  digitalWrite(3, HIGH);
  seg.two();
  digitalWrite(3, LOW);
  delay(2);
  digitalWrite(4, HIGH);
  seg.three();
  digitalWrite



Header File:

Quote

#ifndef Seg_h
#define Seg_h

#include "WProgram.h"

class Seg
{
  public:
  Seg();
  void one();
  void two();
  void three();
  void four();
  void five();
  void six();
  void seven();
  void eight();
  void nine();
  void zero();
  private:
};

#endif




Source File:
Quote

#include "WProgram.h"
#include "Seg.h"

 Seg::Seg()
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
}
void Seg::one()
{
  digitalWrite(6, HIGH);
  digitalWrite(7, LOW);
  digitalWrite(8, LOW);
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);
  digitalWrite(11, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(13, HIGH);
}
void Seg::two()
{
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  digitalWrite(8, HIGH);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);
  digitalWrite(11, HIGH);
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH);
}
So on and so forth to 9.

This is a library to control a 4 digit, 7segment led display.

When I try to compile what i have so far it highlights "  seg.one();" and says "seg_seg:11: error: request for member 'one' in 'seg', which is of non-class type 'Seg () ()'"


Any ways to fix this?

Thanks

johnwasser

This declares a function which RETURNS a Seg:
Code: [Select]
Seg seg();

I think what you intended to do was declare "seg" as an instance of Seg:
Code: [Select]
Seg seg;
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

robtillaart

Post you r code so we can see all of it.

And please use the # button for posting code to get it proper tagged with [ code] tags, looks so much better.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

N314

It was too long so i couldnt post it, i only cout out the repetitive stuff.

N314

I did "Seg seg;" instead of "Seg seg();" and it worked. Thanks

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy