| Author |
Message |
blue hell
Site Admin

Joined: Apr 03, 2004 Posts: 24652 Location: The Netherlands, Enschede
Audio files: 326
G2 patch files: 320
|
Posted: Sat Dec 12, 2020 8:27 pm Post subject:
|
 |
|
it means that it can not find the function named scanColumn .. you may have mistyped it where it is defined .. for instance as ScanColumn .. as things are case sensitive.
To get some ideas about scoping .. that is where things are to be found in the program text see :: https://en.wikipedia.org/wiki/Scope_(computer_science)
edit: hmm .. it wont do an URL like that here .. you'll need to select/copy/paste it (including the parenthized bit). _________________ Jan
also .. could someone please turn down the thermostat a bit.
 |
|
|
Back to top
|
|
 |
floating-water
Joined: Oct 06, 2020 Posts: 62 Location: UK
|
Posted: Sat Dec 12, 2020 8:46 pm Post subject:
|
 |
|
It's typed as:
| Code: | | scanColumn(colCtr); |
the whole code is:
| Code: | #define NUM_ROWS 8
#define NUM_COLS 8
#define NOTE_ON_CMD 0x90
#define NOTE_OFF_CMD 0x80
#define NOTE_VELOCITY 127
//MIDI baud rate
#define SERIAL_RATE 31250
// Pin Definitions
// Row input pins
const int row1Pin = 2;
const int row2Pin = 3;
const int row3Pin = 4;
const int row4Pin = 5;
const int row5Pin = 6;
const int row6Pin = 7;
const int row7Pin = 8;
const int row8Pin = 9;
// 74HC595 pins
const int dataPin = 10;
const int latchPin = 11;
const int clockPin = 12;
boolean keyPressed[NUM_ROWS][NUM_COLS];
uint8_t keyToMidiMap[NUM_ROWS][NUM_COLS];
// bitmasks for scanning columns
int bits[] =
{
B00000001,
B00000010,
B00000100,
B00001000,
B00010000,
B00100000,
B01000000,
B10000000
};
void setup()
{
int note = 36;
for(int colCtr = 0; colCtr < NUM_COLS; ++colCtr)
{
for(int rowCtr = 0; rowCtr < NUM_ROWS; ++rowCtr)
{
keyPressed[rowCtr][colCtr] = false;
keyToMidiMap[rowCtr][colCtr] = note;
note++;
}
}
// setup pins output/input mode
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(row1Pin, INPUT);
pinMode(row2Pin, INPUT);
pinMode(row3Pin, INPUT);
pinMode(row4Pin, INPUT);
pinMode(row5Pin, INPUT);
pinMode(row6Pin, INPUT);
pinMode(row7Pin, INPUT);
pinMode(row8Pin, INPUT);
Serial.begin(SERIAL_RATE);
}
void loop()
{
for (int colCtr = 0; colCtr < NUM_COLS; ++colCtr)
{
//scan next column
scanColumn(colCtr);
//get row values at this column
int rowValue[NUM_ROWS];
rowValue[0] = digitalRead(row1Pin);
rowValue[1] = digitalRead(row2Pin);
rowValue[2] = digitalRead(row3Pin);
rowValue[3] = digitalRead(row4Pin);
rowValue[4] = digitalRead(row5Pin);
rowValue[5] = digitalRead(row6Pin);
rowValue[6] = digitalRead(row7Pin);
rowValue[7] = digitalRead(row8Pin);
// process keys pressed
for(int rowCtr=0; rowCtr<NUM_ROWS; ++rowCtr)
{
if(rowValue[rowCtr] != 0 && !keyPressed[rowCtr][colCtr])
{
keyPressed[rowCtr][colCtr] = true;
noteOn(rowCtr,colCtr);
}
}
// process keys released
for(int rowCtr=0; rowCtr<NUM_ROWS; ++rowCtr)
{
if(rowValue[rowCtr] == 0 && keyPressed[rowCtr][colCtr])
{
keyPressed[rowCtr][colCtr] = false;
noteOff(rowCtr,colCtr);
}
}
}
}
}
void scanColumn(int colNum)
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, bits[colNum]); //left sr
digitalWrite(latchPin, HIGH);
}
void noteOn(int row, int col)
{
Serial.write(NOTE_ON_CMD);
Serial.write(keyToMidiMap[row][col]);
Serial.write(NOTE_VELOCITY);
}
void noteOff(int row, int col)
{
Serial.write(NOTE_OFF_CMD);
Serial.write(keyToMidiMap[row][col]);
Serial.write(NOTE_VELOCITY);
} |
edit: it seems to be in the code correctly is what i mean by this |
|
|
Back to top
|
|
 |
PHOBoS

Joined: Jan 14, 2010 Posts: 5947 Location: Moon Base
Audio files: 709
|
Posted: Sun Dec 13, 2020 4:54 am Post subject:
|
 |
|
| floating-water wrote: | When I tried compiling the sketch it gave an error:
'scanColumn' was not declared in this scope
|
when I get that error it usually means I forget a } somewhere else or maybe added one too many, usually as a result
of having a bunch of nested IF or FOR statements. The problem with that error is that is doesn't really tell you where that actually is.
I'll have a look at the code later,
testing wiki link with html: wikipedia Scope (computer science) _________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube Last edited by PHOBoS on Sun Dec 13, 2020 5:19 am; edited 1 time in total |
|
|
Back to top
|
|
 |
PHOBoS

Joined: Jan 14, 2010 Posts: 5947 Location: Moon Base
Audio files: 709
|
|
|
Back to top
|
|
 |
floating-water
Joined: Oct 06, 2020 Posts: 62 Location: UK
|
Posted: Sun Dec 13, 2020 2:05 pm Post subject:
|
 |
|
| Thanks my guy it worked |
|
|
Back to top
|
|
 |
floating-water
Joined: Oct 06, 2020 Posts: 62 Location: UK
|
Posted: Sun Dec 13, 2020 2:27 pm Post subject:
|
 |
|
Another problem, its stuck on uploading.
Its an arduino nano, its on port COM 5 its looks all set but wont upload, its a clone arduino nano |
|
|
Back to top
|
|
 |
PHOBoS

Joined: Jan 14, 2010 Posts: 5947 Location: Moon Base
Audio files: 709
|
|
|
Back to top
|
|
 |
floating-water
Joined: Oct 06, 2020 Posts: 62 Location: UK
|
Posted: Thu Dec 24, 2020 6:20 am Post subject:
|
 |
|
| for anyone that encounters this problem with a clone, i switched to the old bootloader and it worked |
|
|
Back to top
|
|
 |
Grumble

Joined: Nov 23, 2015 Posts: 1320 Location: Netherlands
Audio files: 30
|
|
|
Back to top
|
|
 |
|