Just a simple LIB, but I'm so new to the Arduino that I'm stranded

Hello,
Sorry to bother, but I have a doubt and problem of who is only working on Arduinos not yet two weeks ago, if you can help me I will be learning without a doubt.
I know of another old but functional language called Clipper, which is more like an advanced Basic, hence my difficulties adapting to Arduino’s C (or even any other).

What I try to do seems simple, but it stuck and I do not know how to solve it. the files are all attached.

What I am trying to do is a library that returns a value to be used in the main routine, just this for now.

I do not know if the error (s) are in the library if it is in the main routine, but it should be basic for the gurus, and thanks for the time, I’m very enthusiastic about playing hardware programming again, I just love it a lot
Details in the main routine,
(still on the limit of writing here every 5 minutes top :frowning:

WByte.h (296 Bytes)

WByte.cpp (661 Bytes)

Main Routine.txt (563 Bytes)

anyone?

Here’s the OP’s code

#include <WByte.h>
int inpin=14; // Port A0

  byte _WValue();
   
  // What I want it to GET from the RETURN from de LIB the string B00000100 as on the WByte.cpp file,
  // just to be used to use later on the line "DDRD = _WValue;", Thas it!!!
  
  WByte wresult(8);
  
void setup() 

{
DDRD = _WValue;
}
void loop(){
if (digitalRead(inpin) == HIGH)  // Verify START Swicht and act upon HIGH
{
PORTD = B00000000;
delay(500);
PORTD = B00000001;
delay(500);
PORTD = B00000010;
delay(500);
PORTD = B00000100;
delay(500);
// AND SO ON
}
}
/*
  RETORNA O VALOR DO BYTE POR EXTENSO (FORMATO B00110011)
  COM BASE NO EU VALOR DE 0 A 255
  
  Criado por António Caldeira, Junho 2018.
*/

#ifndef WByte_h
#define WByte_h

#include "Arduino.h"

class WByte
{
  public:
    WByte(int WValue);
    void WResult();

};
#endif
/*
  RETORNA O VALOR DO BYTE POR EXTENSO (FORMATO B00110011)
  COM BASE NO SEU VALOR DE 0 A 255
  
  Criado por António Caldeira, Junho 2018.
  
*/

#include "Arduino.h"
#include "WByte.h"

byte _WValue;

WByte::WByte(int WValue)

void WByte::WResult
{

if (wvalue==0)
_WValue=B00000000;

else if (wvalue==1)
_WValue=B00000001;

else if (wvalue==3)
_WValue=B00000011;

else if (wvalue==4)
_WValue=B00000100;

else if (wvalue==5)
_WValue=B00000101;

else if (wvalue==6)
_WValue=B00000110;

else if (wvalue==7)
_WValue=B00000111;

else if (wvalue==8)
_WValue=B00000100;

else
_WValue=B11111111;


return(_WValue)
}

OP. It isn't clear what you want this code to do and it is so poorly written that I can't tell. You're going to have to make this an answerable question by adding the needed details.

byte _WValue();

Why are the parenthesis there. You don't have any function names _WValue. so this is an error.

WByte wresult(8);

Here you call your classes constructor BUT:

WByte::WByte(int WValue)

but you didn't implement your constructor. This is also an error. There is no body to this function.

DDRD = _WValue;

You're setting DDRD equal to _WValue which:

byte _WValue;

you never gave any value to. So it is zero. So all pins are set to input and you won't see anything blink in loop.

You have this in your .cpp:

void WByte::WResult
{

Is that a function definition? You're missing the parenthesis. That's an error.

But that function is never called from any of your other code, so why is it even there?

It looks like you need to do some basic C++ tutorials and learn some of the basics of the language before you jump into something as complex as creating objects. Learn to crawl first, then walk, then run.

You're absolutely right.

I got home two hours ago and I saw this answer, which I really appreciate, in fact I learned some things with your explanation, and I went to mess with the code only with this information.

And you're right, it's still too early to try to make a library, Clipper's logic has nothing to do with this language.

I'll be back when I feel more comfortable with this new world (not yet two weeks :slight_smile:

Thank you very much in the same, regards.

AntonioCaldeira:
I know of another old but functional language called Clipper, which is more like an advanced Basic, hence my difficulties adapting to Arduino’s C (or even any other).

I suggest you google “C++ tutorial” and do a C++ tutorial. A few hours on that will benefit you far more than trying to fix your code by getting advice in pieces from the forum.

Run and modify the example code in the IDE’s Examples menu. Then you will know how to structure an Arduino program. Comment in English if you can - your English here seems fine. If folks can read your comments, the code will make so much more sense!