electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
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 » Arduino
Arduino and shiftregisters
Post new topic   Reply to topic
Page 1 of 1 [1 Post]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
PHOBoS



Joined: Jan 14, 2010
Posts: 5591
Location: Moon Base
Audio files: 705

PostPosted: Wed Apr 04, 2018 2:37 pm    Post subject: Arduino and shiftregisters
Subject description: controlling the 74HCT595
Reply with quote  Mark this post and the followings unread

Since easter I started using my first Arduino which is a nano V3 (chinese clone).
To expand the inputs and outputs and make it easier to control things I made an interface a while ago.
It was originally created to use with a PIC to contol lights, but turned out to be useful for controlling synths
and of course I can just as easily use an arduino for it.

So I tested it and controlling the outputs worked right away but I had problems with the inputs. After messing
around with the code for a couple of hours I went back to using a PIC to see if the interface was still working.
I did initially have some problems and I don't know if there might have been some corroded connectors but
I got it to work.

I went back to the arduino and noticed that the values for the inputs I was reading where 1 to high.
(0 was 1, 1 was 2, etc.). I searched around a bit and found a replacement code for the shiftIn function.

Code:
uint8_t naShiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
  uint8_t value = 0;
  uint8_t i;
  for (i = 0; i < 8; ++i) {
    // digitalWrite(clockPin, HIGH);  // old location of clock HIGH
    if (bitOrder == LSBFIRST)
      value |= digitalRead(dataPin) << i;
    else
      value |= digitalRead(dataPin) << (7 - i);
    digitalWrite(clockPin, HIGH);  // new location of clock HIGH
    digitalWrite(clockPin, LOW);
  }
  return value;
}


I found it here and it points to a github link but that is no longer vallid.

So if you run into a similar problem this might solve it.

_________________
"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
Display posts from previous:   
Post new topic   Reply to topic
Page 1 of 1 [1 Post]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Arduino
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