electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Musical Interfaces
turning old piano into midi keyboard (keyboard matrix)
Post new topic   Reply to topic
Page 2 of 2 [34 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Goto page: Previous 1, 2
Author Message
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 23489
Location: The Netherlands, Enschede
Audio files: 262
G2 patch files: 320

PostPosted: Sat Dec 12, 2020 8:27 pm    Post subject: Reply with quote  Mark this post and the followings unread

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.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
floating-water



Joined: Oct 06, 2020
Posts: 55
Location: UK

PostPosted: Sat Dec 12, 2020 8:46 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 5078
Location: Moon Base
Audio files: 673

PostPosted: Sun Dec 13, 2020 4:54 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
PHOBoS



Joined: Jan 14, 2010
Posts: 5078
Location: Moon Base
Audio files: 673

PostPosted: Sun Dec 13, 2020 5:01 am    Post subject: Reply with quote  Mark this post and the followings unread

Code:

....
    // 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);
      }
    }
  }
}

}


in that section the last } needs to go

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
floating-water



Joined: Oct 06, 2020
Posts: 55
Location: UK

PostPosted: Sun Dec 13, 2020 2:05 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thanks my guy it worked
Back to top
View user's profile Send private message
floating-water



Joined: Oct 06, 2020
Posts: 55
Location: UK

PostPosted: Sun Dec 13, 2020 2:27 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 5078
Location: Moon Base
Audio files: 673

PostPosted: Fri Dec 18, 2020 11:43 am    Post subject: Reply with quote  Mark this post and the followings unread

do you get some kind of error message or does it just try to upload and then nothing happens and it keeps stuck on uploading ?
I've had that before but I think my solution was just to switch from windows to linux or the other way around. I guess that's not very helpful.

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
floating-water



Joined: Oct 06, 2020
Posts: 55
Location: UK

PostPosted: Thu Dec 24, 2020 6:20 am    Post subject: Reply with quote  Mark this post and the followings unread

for anyone that encounters this problem with a clone, i switched to the old bootloader and it worked
Back to top
View user's profile Send private message
Grumble



Joined: Nov 23, 2015
Posts: 1205
Location: Netherlands
Audio files: 30

PostPosted: Thu Dec 24, 2020 9:18 am    Post subject: Reply with quote  Mark this post and the followings unread

PHOBoS wrote:
do you get some kind of error message or does it just try to upload and then nothing happens and it keeps stuck on uploading ?
I've had that before but I think my solution was just to switch from windows to linux or the other way around. I guess that's not very helpful.

I’ve had this problem many times, didn’t bother with bootloading but turned to using Atmel studio using an external programmer avr isp2


1DC3FE09-C37D-4E46-9CBA-0A4D0D89A2DD.jpeg
 Description:
 Filesize:  44.6 KB
 Viewed:  239 Time(s)

1DC3FE09-C37D-4E46-9CBA-0A4D0D89A2DD.jpeg



_________________
my synth
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic
Page 2 of 2 [34 Posts]
View unread posts
View new posts in the last week
Goto page: Previous 1, 2
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Musical Interfaces
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use