Senior Projects can be rough from an IP standpoint. I'm not speaking as a lawyer, but I am speaking as someone who manages many senior projects and is in the middle of working out the IP status of the students with our univ counsel.
For your specific case, we're missing some of the specific details, like exactly what were the resources put into the project, etc, and exactly what were the circumstances and communications involved (please don't provide that as comment -- I'm not particularly interested, but will try to cover a variety of scenarios and you can place yourself in whatever box you see as appropriate).
My recommendation is if you worked on this FOR a specific lab or department, and they helped you evaluate and debug, and no discussions of ownership took place a priori, and the ONLY possible users are the people you've been working with, then I would allow them to keep using your code without charge REGARDLESS of whatever legitimate IP claims you actually have, and chalk it up to experience and lessons learned. If the groups needs any further development or support, let them know that you're willing to handle it on a consultant basis. Note this has nothing to do with what's legal or what your real claims are. It has to do with professionalism, making payments and deliverables clear before work is started, leaving behind a swath of people who feel good about working with you as opposed to people who regret having worked with you.
If you really plan to develop your code, improve it, and market and sell it beyond the boundaries of that one department, then there may be clear disadvantages to just handing them your IP, and you should start a business and consult with a lawyer. Personally, I would think in that case your best bet, or at least a good option, is to formally grant the users non-exclusive use of the code at no cost, just to make it clear that you are holding on to your IP and not giving it away.
In all cases, you should make sure that if money is going to be made in the future with this code that you will be part of it or all of it! Thus, even if you decide to just let the department continue to use it, and have no plans to ever sell it elsewhere, you might want to go through the exercise of establishing a license, just to establish ownership in case the department ever wants to sell it on their own.
Of course, getting the right sort of licensing contract might just mean hiring a lawyer, and thus spending money. You'd have to figure out if that's worth it, unless there are some kind of templates out there.
In our own design course, we certainly don't want anyone taking advantage of our students from an IP perspective. That said, we have "customers" for every prototype we generate, and if we cut off our customers from the fruits of the project, we wouldn't have many future customers. We have had IP come out of the class, and some of the patents have been assigned to the university with students as inventors if the university has contributed substantial resources to the project, or if a faculty member is one of the inventors. Others, where the university has not contributed much in the way of resources, go to the students, who are free to do with it as they chose. Some have spun out businesses. In either case, we would NEVER cut the customer out from at least being able to USE the prototype. It would be shoddy.